dotfiles/.config/fish/functions/update.fish

47 lines
1.4 KiB
Fish

function update --description "Update everything"
# TODO: add configuration options and publish?
sudo -v
set -l termcmd foot fish -c
set -l lines 'cargo install-update -a
gup update
uv tool upgrade --all
flatpak update -y
yes | paru -Syu'
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
if string match -q "*paru *" -- "$cmd"
eval $cmd
else
$termcmd $cmd &>/dev/null &
end
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