config/shell: restructure yzf cache
This commit is contained in:
parent
a24971bd5c
commit
508826c826
|
@ -6,18 +6,21 @@ alias dragon='dragon-drag-and-drop'
|
||||||
alias pac='noglob sudo pacman'
|
alias pac='noglob sudo pacman'
|
||||||
alias pacs='pac -Syu --needed'
|
alias pacs='pac -Syu --needed'
|
||||||
alias pacr='pac -R'
|
alias pacr='pac -R'
|
||||||
alias yays='noglob yay -S --needed --ignore ferdi'
|
alias yays='noglob yay -Sy --needed --ignore ferdi'
|
||||||
alias yayr='noglob yay -R'
|
alias yayr='noglob yay -R'
|
||||||
|
|
||||||
yzf() {
|
yzf() {
|
||||||
query=$(test "$1" = "Q" && echo " -l")
|
query=$(test "$1" = "Q" && echo " -l")
|
||||||
sync=$(test "$1" = "S" && echo "true" || echo "")
|
sync=$(test "$1" = "S" && echo "true" || echo "")
|
||||||
pos=$(test "$query" && echo 1 || echo 2)
|
pos=$(test "$query" && echo 1 || echo 2)
|
||||||
list_cache="/tmp/yzf-$1$2"
|
cache_dir="/tmp/yzf"
|
||||||
|
mkdir -p $cache_dir
|
||||||
|
list_cache="$cache_dir/list_$1$2"
|
||||||
|
preview_cache="$cache_dir/preview_{$pos}"
|
||||||
(test "$sync" && cat "$list_cache" 2>/dev/null || yay --color always -$1$2 | sed "s/ /\t/g" | tee "$list_cache") |
|
(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 \
|
fzf --nth=$pos --multi --tiebreak=length --history=/var/tmp/fzf-history-yay \
|
||||||
--bind="double-click:execute(xdg-open 'https://archlinux.org/packages/{$pos}')" \
|
--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 |
|
--preview "$(test "$sync" && echo "cat $preview_cache 2>/dev/null | grep -v 'Querying' | grep . ||") yay --color always -$1 -i $query {$pos} | tee $preview_cache" "${@:3}" --preview-window=wrap |
|
||||||
cut -f$pos
|
cut -f$pos
|
||||||
# TODO get xdg-open URL for aur as well
|
# TODO get xdg-open URL for aur as well
|
||||||
# yay -S -i {$pos} | grep URL | tail -1 | cut -d ':' -f2- | xargs xdg-open
|
# yay -S -i {$pos} | grep URL | tail -1 | cut -d ':' -f2- | xargs xdg-open
|
||||||
|
|
|
@ -193,7 +193,7 @@ alias jc='jcl -u'
|
||||||
alias jcj='jcl -o json-pretty -u'
|
alias jcj='jcl -o json-pretty -u'
|
||||||
|
|
||||||
alias grp='grep --line-number --ignore-case --binary-files=without-match --directories=skip'
|
alias grp='grep --line-number --ignore-case --binary-files=without-match --directories=skip'
|
||||||
alias grpr='grp --recursive --exclude-dir={.sync,.stfolder,.git}'
|
alias grpr='grp --recursive --exclude-dir={.sync,.stfolder,.git,dev,\*build}'
|
||||||
|
|
||||||
# Recover stray swap files from neovim
|
# Recover stray swap files from neovim
|
||||||
alias vrec="ls $XDG_DATA_HOME/nvim/swap | sed 's/\%/\//g' | sed 's|\(.*\)\..*|\1|' | head -1 | xargs -r nvim"
|
alias vrec="ls $XDG_DATA_HOME/nvim/swap | sed 's/\%/\//g' | sed 's|\(.*\)\..*|\1|' | head -1 | xargs -r nvim"
|
||||||
|
@ -225,14 +225,14 @@ updateDeps() {
|
||||||
pattern="$2"
|
pattern="$2"
|
||||||
depth="4"
|
depth="4"
|
||||||
case $name in
|
case $name in
|
||||||
gradle-wrapper.properties) depth=6;;
|
(gradle-wrapper.properties) depth=6;;
|
||||||
esac
|
esac
|
||||||
shift 2
|
shift 2
|
||||||
oldversion="[0-9.]\+"
|
oldversion="[0-9.]\+"
|
||||||
while test $# -gt 1; do
|
while test $# -gt 1; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--pattern) oldversion="$2";;
|
(--pattern) oldversion="$2";;
|
||||||
--version) version="$2";;
|
(--version) version="$2";;
|
||||||
esac
|
esac
|
||||||
shift 2
|
shift 2
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue