TheRepoClub-DotFiles/localbin/.local/bin/pacsync
The-Repo-Club 703e9f5b5d
Update
2022-10-27 22:43:30 +01:00

108 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
#-*-coding:utf-8 -*-
#Auto updated?
# Yes
#File:
# pacsync
#Author:
# The-Repo-Club [wayne6324@gmail.com]
#Github:
# https://github.com/The-Repo-Club/
#
#Created:
# Tue 25 October 2022, 07:04:14 AM [GMT+1]
#Modified:
# Thu 27 October 2022, 10:10:40 PM [GMT+1]
#
#Description:
# FZF menu for pacman yay or pikaur
#
#Dependencies:
# bash, pacman, yay, pikaur
#
function go_pacman() {
cmd=$(pacman -Slq | fzf --prompt 'pacman> ' \
--header 'Install packages. CTRL+[P/Y/R/I/Q] (Pacman/Yay/Paru/Installed/Quit)' \
--bind 'ctrl-p:change-prompt(pacman> )+reload(pacman -Slq)' \
--bind 'ctrl-y:change-prompt(yay> )+reload(yay -Slq)' \
--bind 'ctrl-r:change-prompt(pikaur> )+reload(pikaur -Slq)' \
--bind 'ctrl-i:change-prompt(inst> )+reload(yay -Qq)' \
--multi --height=80% --preview 'sleep 2; yay -Si {1}' \
--preview-window 'right,wrap' \
--reverse --header-first) #| xargs -ro pacman -S
cmd=${cmd//$'\n'/ } # newline -> space
if [ -n "$cmd" ]; then
yay -S "$cmd"
fi
exit
}
function go_yay() {
cmd=$(yay -Slq | fzf --prompt 'yay> ' \
--header 'Install packages. CTRL+[P/Y/R/I/Q] (Pacman/Yay/Paru/Installed/Quit)' \
--bind 'ctrl-p:change-prompt(pacman> )+reload(pacman -Slq)' \
--bind 'ctrl-y:change-prompt(yay> )+reload(yay -Slq)' \
--bind 'ctrl-r:change-prompt(pikaur> )+reload(pikaur -Slq)' \
--bind 'ctrl-i:change-prompt(inst> )+reload(yay -Qq)' \
--multi --height=80% --preview 'sleep 2; yay -Si {1}' \
--preview-window 'right,wrap' \
--reverse --header-first) #| xargs -ro yay -S
cmd=${cmd//$'\n'/ } # newline -> space
if [ -n "$cmd" ]; then
yay -S "$cmd"
fi
exit
}
function go_paru() {
cmd=$(pikaur -Slq | fzf --prompt 'pikaur> ' \
--header 'Install packages. CTRL+[P/Y/R/I/Q] (Pacman/Yay/Paru/Installed/Quit)' \
--bind 'ctrl-p:change-prompt(pacman> )+reload(pacman -Slq)' \
--bind 'ctrl-y:change-prompt(yay> )+reload(yay -Slq)' \
--bind 'ctrl-r:change-prompt(pikaur> )+reload(pikaur -Slq)' \
--bind 'ctrl-i:change-prompt(inst> )+reload(yay -Qq)' \
--multi --height=80% --preview 'sleep 2; yay -Si {1}' \
--preview-window 'right,wrap' \
--reverse --header-first) #| xargs -ro pikaur -S
cmd=${cmd//$'\n'/ } # newline -> space
if [ -n "$cmd" ]; then
yay -S "$cmd"
fi
exit
}
function go_installed() {
cmd=$(pacman -Qq | fzf --prompt 'installed> ' \
--header 'Installed packages. CTRL+[P/Y/R/I/Q] (Pacman/Yay/Paru/Installed/Quit)' \
--bind 'ctrl-p:change-prompt(pacman> )+reload(pacman -Slq)' \
--bind 'ctrl-y:change-prompt(yay> )+reload(yay -Slq)' \
--bind 'ctrl-r:change-prompt(pikaur> )+reload(pikaur -Slq)' \
--bind 'ctrl-i:change-prompt(installed> )+reload(yay -Qq)' \
--multi --height=80% --preview 'sleep 2; yay -Si {1}' \
--preview-window 'right,wrap' \
--reverse --header-first) #| xargs -ro pacman -S
cmd=${cmd//$'\n'/ } # newline -> space
if [ -n "$cmd" ]; then
yay -S "$cmd"
fi
exit
}
case $1 in
*pacman)
go_pacman
;;
*yay)
go_yay
;;
*pikaur)
go_paru
;;
*installed)
go_installed
;;
*)
go_pacman
;;
esac