From 8b107372d340614229cef84ce26eb10b09e45689 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Thu, 22 Apr 2021 19:37:32 +0200 Subject: [PATCH] config/shell: add caching to yzf --- .config/shell/arch | 10 +++++++++- .config/shell/functions | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.config/shell/arch b/.config/shell/arch index a3365ec..bc37b1c 100644 --- a/.config/shell/arch +++ b/.config/shell/arch @@ -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}") diff --git a/.config/shell/functions b/.config/shell/functions index a57e564..44cb344 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -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"