FZF xbps menu

This commit is contained in:
~erin 2023-04-01 18:23:33 -04:00
parent fe526293e0
commit 5a27ca1068
Signed by: erin
GPG Key ID: 9A8E308CEFA37A47
1 changed files with 19 additions and 0 deletions

19
functions/fbps.fish Normal file
View File

@ -0,0 +1,19 @@
function fbps
argparse 'h/help' 'i/install' 'r/remove' -- $argv
or return
set --local -x FZF_DEFAULT_OPTS '--cycle --layout=reverse --border --height=40% --preview-window=wrap --marker="*" --color=bg+:#313244,spinner:#f5e0dc,hl:#f38ba8 --color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc --color=marker:#f5e0dc,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8'
if set -ql _flag_remove
xbps-query -l | rg -o --pcre2 '(?<=\\w{2}\\s)[A-z-]*(?=-\\d+.*)' | fzf -q "$1" -m --preview 'xbps-query {1} | bat -p --language yaml --color=always' | xargs -ro sudo xbps-remove
else if set -ql _flag_install
xbps-query -Rs '*' | rg -o --pcre2 '(?<=\[-\]\s)[\w-]*(?=-\d+.*)' | fzf -q "$1" -m --preview 'xbps-query -R {1} | bat -p --language yaml --color=always' | xargs -ro sudo xbps-install
else
echo -e "Usage: fbps [MODE]\n"
echo "MODE"
echo -e " -i --install\tInstall a remote package"
echo -e " -r --remove\tRemove an installed package"
return 0
end
end