From 90fef97ba4050fa4417d301378d0b3bfe2d1c47f Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Tue, 29 Apr 2025 14:00:06 -0400 Subject: [PATCH] AutoYADM commit: 2025-04-29 14:00:05 --- .config/fish/functions/update.fish | 61 +++++++++++++++++++----------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/.config/fish/functions/update.fish b/.config/fish/functions/update.fish index f8c23f10..f1b82d81 100644 --- a/.config/fish/functions/update.fish +++ b/.config/fish/functions/update.fish @@ -1,38 +1,57 @@ function update --description "Update everything" + # autoconfirm + argparse y/no-confirm -- $argv # TODO: add configuration options and publish? - sudo -v set -l termcmd foot fish -c - set -l lines 'cargo install-update -a + set -l std 'cargo install-update -a gup update -uv tool upgrade --all -flatpak update -y +uv tool upgrade --all ' + set -l noconfirm 'flatpak update -y yes | paru -Syu' - set -l cmds (string split \n -- $lines | string trim) + set -l confirm 'flatpak update +paru -Syu' + set -l cmds (string split \n -- $std | string trim) + if set -q _flag_y + set --append cmds $noconfirm + sudo -v + else + set --append cmds $confirm + end echo Commands to be run: for i in $cmds echo $i end + return 0 + function execute -a cmds + argparse i/interactive -- $argv + if set -ql _flag_i + for cmd in $cmds + # max 2 jobs at a time + while test (count (jobs -p)) -ge 2 + sleep 0.5 + end + if string match -q "*paru *" -- "$cmd" + eval $cmd + else + $termcmd $cmd &>/dev/null & + end + end + else + for cmd in $cmds + eval $cmd + end + end + end + if isatty stdin; and isatty stdout while read --nchars 1 -l response --prompt-str="Run on multiple terminals? (y/n)" or return 1 switch $response case y Y - for cmd in $cmds - # max 2 jobs at a time - while test (count (jobs -p)) -ge 2 - sleep 0.5 - end - if string match -q "*paru *" -- "$cmd" - eval $cmd - else - $termcmd $cmd &>/dev/null & - end - end + execute --interactive $cmds wait break case n N - for cmd in $cmds - eval $cmd - end + execute $cmds break case '*' echo Invalid input! @@ -40,8 +59,6 @@ yes | paru -Syu' end end else - for cmd in $cmds - eval $cmd - end + execute $cmds end end