TheRepoClub-DotFiles/localbin/.local/bin/pacsync

63 lines
1.7 KiB
Plaintext
Raw Normal View History

2022-09-05 12:16:33 -04:00
#!/usr/bin/bash
# Dependencies:
# pacman, yay, fzf
function go_pacman() {
cmd=$(pacman -Slq | fzf --prompt 'pacman> ' \
--header 'Install packages. CTRL+(Pacman/Aur/Installed/Quit)' \
--bind 'ctrl-p:change-prompt(pacman> )+reload(pacman -Slq)' \
--bind 'ctrl-a:change-prompt(yay> )+reload(yay -Slq)' \
--bind 'ctrl-i:change-prompt(inst> )+reload(yay -Qq)' \
--multi --height=80% --preview 'sleep 2; yay -Si {1}' \
--preview-window right) #| xargs -ro yay -S
cmd=${cmd//$'\n'/ } # newline -> space
if [ -n "$cmd" ]; then
yay -S "$cmd"
2022-09-05 12:16:33 -04:00
fi
exit
}
function go_yay() {
cmd=$(yay -Slq | fzf --prompt 'yay> ' \
--header 'Install packages. CTRL+(Pacman/Aur/Installed/Quit)' \
--bind 'ctrl-p:change-prompt(pacman> )+reload(pacman -Slq)' \
--bind 'ctrl-a:change-prompt(yay> )+reload(yay -Slq)' \
--bind 'ctrl-i:change-prompt(inst> )+reload(yay -Qq)' \
--multi --height=80% --preview 'sleep 2; yay -Si {1}' \
--preview-window right) #| xargs -ro yay -S
cmd=${cmd//$'\n'/ } # newline -> space
if [ -n "$cmd" ]; then
yay -S "$cmd"
2022-09-05 12:16:33 -04:00
fi
exit
}
function go_installed() {
cmd=$(yay -Qq | fzf --prompt 'installed> ' \
--header 'Install packages. CTRL+(Pacman/Aur/Installed/Quit)' \
--bind 'ctrl-p:change-prompt(pacman> )+reload(pacman -Slq)' \
--bind 'ctrl-a:change-prompt(yay> )+reload(yay -Slq)' \
--bind 'ctrl-i:change-prompt(installed> )+reload(yay -Qq)' \
--multi --height=80% --preview 'sleep 2; yay -Si {1}' \
--preview-window right) #| xargs -ro yay -S
cmd=${cmd//$'\n'/ } # newline -> space
if [ -n "$cmd" ]; then
yay -S "$cmd"
2022-09-05 12:16:33 -04:00
fi
exit
}
case $1 in
*pacman)
go_pacman
;;
*yay)
go_yay
;;
*installed)
go_installed
;;
*)
go_pacman
;;
esac