function update --description "Update everything" # autoconfirm # or force no multiterm argparse h/help y/no-confirm o/one-term -- $argv if set -ql _flag_h printf '%s\n' \ 'update -- update everything' \ 'Usage: run `update` to begin' \ 'Options:' \ '-y/--no-confirm: Skip update confirmations' \ '-o/--one-term: Force single terminal mode' \ '-h/--help: Print this screen' return 0 end # TODO add way for user to configure the update list? set -g termcmd foot fish -c set -l std 'cargo install-update -a gup update uv tool upgrade --all' set -l noconfirm 'flatpak update -y yes | paru -Syu' set -l confirm 'flatpak update paru -Syu' set -g cmds (string split \n -- $std | string trim) if set -q _flag_y set --append cmds (string split \n -- $noconfirm | string trim) sudo -v else set --append cmds (string split \n -- $confirm | string trim) end echo Commands to be run: for i in $cmds echo $i end function execute 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 not set -ql _flag_o && isatty stdin && isatty stdout while read --nchars 1 -l response --prompt-str="Run on multiple terminals? (y/n)" or return 1 switch $response case y Y execute --interactive wait break case n N execute break case '*' echo Invalid input! continue end end else execute end end