function update --description "Update everything" 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