config/shell: add caching to yzf

This commit is contained in:
xerus2000 2021-04-22 19:37:32 +02:00
parent b23515c424
commit 8b107372d3
2 changed files with 12 additions and 2 deletions

View File

@ -11,8 +11,16 @@ alias yayr='noglob yay -R'
yzf() {
query=$(test "$1" = "Q" && echo " -l")
sync=$(test "$1" = "S" && echo "true" || echo "")
pos=$(test "$query" && echo 1 || echo 2)
yay --color always -$1$2 | sed "s/ /\t/g" | fzf --multi --tiebreak=length --history=/var/tmp/fzf-history-yay --bind='left-click:ignore' --preview "echo {} | cut -f$pos | xargs yay --color always -$1 -i $query" "${@:3}" | cut -f$pos
list_cache="/tmp/yzf-$1$2"
(test "$sync" && cat "$list_cache" 2>/dev/null || yay --color always -$1$2 | sed "s/ /\t/g" | tee "$list_cache") |
fzf --nth=$pos --multi --tiebreak=length --history=/var/tmp/fzf-history-yay \
--bind="double-click:execute(xdg-open 'https://archlinux.org/packages/{$pos}')" \
--preview "$(test "$sync" && echo "cat /tmp/yzf-{$pos} 2>/dev/null | grep -v 'Querying' | grep . ||") yay --color always -$1 -i $query {$pos} | tee /tmp/yzf-{$pos}" "${@:3}" --preview-window=wrap |
cut -f$pos
# TODO get xdg-open URL for aur as well
# yay -S -i {$pos} | grep URL | tail -1 | cut -d ':' -f2- | xargs xdg-open
}
yas() {
pkg=$(yzf S l -q "$1" "${@:2}")

View File

@ -5,6 +5,7 @@ alias -g ___='"$(eval "$(fc -ln -1)" | tail -n 1)"'
alias -g G="| grp"
alias -g X="| xargs"
alias -g X1="| xargs -n 1"
alias -g XC="| xclip -selection clipboard"
alias -g L="--color=always | less"
fi
@ -282,7 +283,8 @@ alias f="noglob $(which fd >/dev/null && echo fd || echo fdfind) --hidden --no-i
#alias f='find -not -path "*.sync*" -and -not \( -name daten -prune \)'
#alias f1='find -mindepth 1 -maxdepth 1'
alias lowercase='tr "A-Z " "a-z-"'
lowercase_transliterate="y/A-Z /a-z-/"
which perl-rename >/dev/null && alias lowercase="perl-rename '$lowercase_transliterate'" || alias lowercase="rename '$lowercase_transliterate'"
mkcd() {
mkdir -p "$1" && cd "$1"