diff --git a/.config/fish/functions/update.fish b/.config/fish/functions/update.fish index 9673e7fb..4212ca84 100644 --- a/.config/fish/functions/update.fish +++ b/.config/fish/functions/update.fish @@ -1,6 +1,41 @@ function update --description "Update everything" - cargo install-update -a - gup update - uv tool upgrade --all - paru -Syu + set -l termcmd foot fish -c + set -l lines 'cargo install-update -a +gup update +uv tool upgrade --all +paru -Syu +flatpak update' + set -l cmds (string split \n -- $lines | string trim) + echo Commands to be run: + for i in $cmds + echo $i + 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 + $termcmd $cmd &>/dev/null & + end + wait + break + case n N + for cmd in $cmds + eval $cmd + end + break + case '*' + echo Invalid input! + continue + end + end + else + for cmd in $cmds + eval $cmd + end + end end