AutoYADM commit: 2025-04-29 14:00:05
This commit is contained in:
parent
7e0e1db700
commit
90fef97ba4
1 changed files with 39 additions and 22 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue