ZSH: Add support for pi alias

No gpg signature this time, yubikey is refusing to work
This commit is contained in:
Marko Korhonen 2022-09-20 23:32:21 +03:00
parent f869d15f7b
commit 0303678c40

View file

@ -23,14 +23,25 @@ function command_not_found_handler {
} }
{%@@ endif @@%} {%@@ endif @@%}
{%@@ if distro_id == "arch" @@%}
# search and install/remove packages with fzf # search and install/remove packages with fzf
pi() { pi() {
{%@@ if distro_id == "arch" @@%}
SELECTED_PKGS="$(paru -Slq | fzf --header='Install packages' -m --preview 'paru -Si {1}')" SELECTED_PKGS="$(paru -Slq | fzf --header='Install packages' -m --preview 'paru -Si {1}')"
{%@@ else @@%}
SELECTED_PKGS="$(apt list 2>/dev/null | cut -d '/' -f 1 | tail +2 | fzf --header='Install packages' -m --preview 'apt show {1}')"
{%@@ endif @@%}
if [ -n "$SELECTED_PKGS" ]; then if [ -n "$SELECTED_PKGS" ]; then
{%@@ if distro_id == "arch" @@%}
cmd="paru -S $(echo $SELECTED_PKGS)"
{%@@ else @@%}
cmd="sudo apt install $(echo $SELECTED_PKGS)"
{%@@ endif @@%}
# Append the expanded command to history # Append the expanded command to history
print -s "paru -S $(echo $SELECTED_PKGS)" print -s "$cmd"
paru -S $(echo $SELECTED_PKGS)
# Finally, excecute the command
eval "$cmd"
fi fi
} }
pr() { pr() {
@ -41,7 +52,6 @@ pr() {
paru -Rns $(echo $SELECTED_PKGS) paru -Rns $(echo $SELECTED_PKGS)
fi fi
} }
{%@@ endif @@%}
{%@@ if distro_id == "termux" @@%} {%@@ if distro_id == "termux" @@%}
alias gp='okc-gpg' alias gp='okc-gpg'