Update pacsync

This commit is contained in:
The-Repo-Club 2022-10-30 12:48:36 +00:00
parent 4bae64d310
commit 0f3257a092
No known key found for this signature in database
GPG Key ID: E30EC2FBFB05C44F

View File

@ -12,7 +12,7 @@
#Created: #Created:
# Tue 25 October 2022, 07:04:14 AM [GMT+1] # Tue 25 October 2022, 07:04:14 AM [GMT+1]
#Modified: #Modified:
# Thu 27 October 2022, 10:10:40 PM [GMT+1] # Sun 30 October 2022, 12:46:18 PM [GMT]
# #
#Description: #Description:
# FZF menu for pacman yay or pikaur # FZF menu for pacman yay or pikaur
@ -20,84 +20,95 @@
#Dependencies: #Dependencies:
# bash, pacman, yay, pikaur # bash, pacman, yay, pikaur
# #
# shellcheck disable=all
colorize() {
local string
string="${1//\[/\\033\[0;32m\[}"
string="${string//\]/\]\\033\[0m}"
echo -n -e "${string}"
}
CP_KEY="ctrl-p"
CA_KEY="ctrl-a"
CI_KEY="ctrl-i"
CQ_KEY="ctrl-q"
TP_KEY="ctrl-t"
HEADER=$(colorize "[ENTER] Install selected [${TP_KEY^^}] Toggle preview
[${CP_KEY^^}] Pacman [${CA_KEY^^}] AUR [${CI_KEY^^}] Installed
[${CQ_KEY^^}] Quit")
function go_pacman() { function go_pacman() {
cmd=$(pacman -Slq | fzf --prompt 'pacman> ' \ cmd=$(pacman -Slq | fzf --prompt ' pacman> ' \
--header 'Install packages. CTRL+[P/Y/R/I/Q] (Pacman/Yay/Paru/Installed/Quit)' \ --header "${HEADER}" \
--bind 'ctrl-p:change-prompt(pacman> )+reload(pacman -Slq)' \ --bind "${CP_KEY}:execute:pacsync 'pacman'" \
--bind 'ctrl-y:change-prompt(yay> )+reload(yay -Slq)' \ --bind "${CA_KEY}:execute:pacsync 'aur'" \
--bind 'ctrl-r:change-prompt(pikaur> )+reload(pikaur -Slq)' \ --bind "${CI_KEY}:execute:pacsync 'installed'" \
--bind 'ctrl-i:change-prompt(inst> )+reload(yay -Qq)' \ --bind "${CQ_KEY}:execute:pkill fzf" \
--bind "${TP_KEY}:toggle-preview" \
--multi --height=80% --preview 'sleep 2; yay -Si {1}' \ --multi --height=80% --preview 'sleep 2; yay -Si {1}' \
--preview-window 'right,wrap' \ --preview-window 'right,wrap') #| xargs -ro pacman -S
--reverse --header-first) #| xargs -ro pacman -S
cmd=${cmd//$'\n'/ } # newline -> space cmd=${cmd//$'\n'/ } # newline -> space
if [ -n "$cmd" ]; then if [ -n "$cmd" ]; then
yay -S "$cmd" pikaur -S "$cmd"
fi fi
exit exit
} }
function go_yay() { function go_aur() {
cmd=$(yay -Slq | fzf --prompt 'yay> ' \ cmd=$(yay -Slq | fzf --prompt ' pikaur> ' \
--header 'Install packages. CTRL+[P/Y/R/I/Q] (Pacman/Yay/Paru/Installed/Quit)' \ --header "${HEADER}" \
--bind 'ctrl-p:change-prompt(pacman> )+reload(pacman -Slq)' \ --bind "${CP_KEY}:execute:pacsync 'pacman'" \
--bind 'ctrl-y:change-prompt(yay> )+reload(yay -Slq)' \ --bind "${CA_KEY}:execute:pacsync 'aur'" \
--bind 'ctrl-r:change-prompt(pikaur> )+reload(pikaur -Slq)' \ --bind "${CI_KEY}:execute:pacsync 'installed'" \
--bind 'ctrl-i:change-prompt(inst> )+reload(yay -Qq)' \ --bind "${CQ_KEY}:execute:pkill fzf" \
--bind "${TP_KEY}:toggle-preview" \
--multi --height=80% --preview 'sleep 2; yay -Si {1}' \ --multi --height=80% --preview 'sleep 2; yay -Si {1}' \
--preview-window 'right,wrap' \ --preview-window 'right,wrap') #| xargs -ro pikaur -S
--reverse --header-first) #| xargs -ro yay -S
cmd=${cmd//$'\n'/ } # newline -> space cmd=${cmd//$'\n'/ } # newline -> space
if [ -n "$cmd" ]; then if [ -n "$cmd" ]; then
yay -S "$cmd" pikaur -R "$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 fi
exit exit
} }
function go_installed() { function go_installed() {
cmd=$(pacman -Qq | fzf --prompt 'installed> ' \ cmd=$(pacman -Qq | fzf --prompt ' installed> ' \
--header 'Installed packages. CTRL+[P/Y/R/I/Q] (Pacman/Yay/Paru/Installed/Quit)' \ --header "${HEADER}" \
--bind 'ctrl-p:change-prompt(pacman> )+reload(pacman -Slq)' \ --bind "${CP_KEY}:execute:pacsync 'pacman'" \
--bind 'ctrl-y:change-prompt(yay> )+reload(yay -Slq)' \ --bind "${CA_KEY}:execute:pacsync 'aur'" \
--bind 'ctrl-r:change-prompt(pikaur> )+reload(pikaur -Slq)' \ --bind "${CI_KEY}:execute:pacsync 'installed'" \
--bind 'ctrl-i:change-prompt(installed> )+reload(yay -Qq)' \ --bind "${CQ_KEY}:execute:pkill fzf" \
--bind "${TP_KEY}:toggle-preview" \
--multi --height=80% --preview 'sleep 2; yay -Si {1}' \ --multi --height=80% --preview 'sleep 2; yay -Si {1}' \
--preview-window 'right,wrap' \ --preview-window 'right,wrap') #| xargs -ro pacman -S
--reverse --header-first) #| xargs -ro pacman -S
cmd=${cmd//$'\n'/ } # newline -> space cmd=${cmd//$'\n'/ } # newline -> space
if [ -n "$cmd" ]; then if [ -n "$cmd" ]; then
yay -S "$cmd" pikaur -R "$cmd"
fi fi
exit exit
} }
if command -v fzf > /dev/null 2>&1; then
FUZZYSEL=fzf
fuzzy_default_options=(
"--inline-info" "--cycle" "--ansi" "-e"
"--no-sort" "--layout=reverse-list"
"--border=${BORDER:-sharp}"
)
export FZF_DEFAULT_OPTS="${fuzzy_default_options[*]}"
else
echo "Unable to find 'fzf' fuzzy finder"
exit
fi
case $1 in case $1 in
*pacman) *pacman)
go_pacman go_pacman
;; ;;
*yay) *aur)
go_yay go_aur
;;
*pikaur)
go_paru
;; ;;
*installed) *installed)
go_installed go_installed