2020-10-14 12:16:36 +00:00
|
|
|
which pacman >/dev/null || return 0
|
2020-10-12 20:20:06 +00:00
|
|
|
|
2020-11-30 21:13:43 +00:00
|
|
|
alias dragon='dragon-drag-and-drop'
|
|
|
|
|
2020-10-12 20:20:06 +00:00
|
|
|
# Arch aliases
|
2020-11-14 01:26:30 +00:00
|
|
|
alias pac='noglob sudo pacman'
|
2020-10-12 20:20:06 +00:00
|
|
|
alias pacs='pac -Syu --needed'
|
|
|
|
alias pacr='pac -R'
|
2021-05-27 20:04:26 +00:00
|
|
|
alias yays='noglob yay -Sy --needed --ignore ferdi'
|
2020-11-14 01:26:30 +00:00
|
|
|
alias yayr='noglob yay -R'
|
|
|
|
|
2021-06-05 18:26:27 +00:00
|
|
|
cache_dir="/tmp/yzf"
|
2020-11-14 01:26:30 +00:00
|
|
|
yzf() {
|
|
|
|
query=$(test "$1" = "Q" && echo " -l")
|
2021-04-22 17:37:32 +00:00
|
|
|
sync=$(test "$1" = "S" && echo "true" || echo "")
|
2020-11-14 01:26:30 +00:00
|
|
|
pos=$(test "$query" && echo 1 || echo 2)
|
2021-05-27 20:04:26 +00:00
|
|
|
mkdir -p $cache_dir
|
|
|
|
list_cache="$cache_dir/list_$1$2"
|
2021-04-22 17:37:32 +00:00
|
|
|
(test "$sync" && cat "$list_cache" 2>/dev/null || yay --color always -$1$2 | sed "s/ /\t/g" | tee "$list_cache") |
|
2021-06-05 18:26:27 +00:00
|
|
|
fzf --nth=$pos --multi --tiebreak=length --history=/var/tmp/fzf-history-yzf \
|
2021-04-22 17:37:32 +00:00
|
|
|
--bind="double-click:execute(xdg-open 'https://archlinux.org/packages/{$pos}')" \
|
2021-06-05 18:26:27 +00:00
|
|
|
"${@:3}" --preview-window=60% |
|
|
|
|
cut -f$pos | tr '\n' ' '
|
2021-04-22 17:37:32 +00:00
|
|
|
# TODO get xdg-open URL for aur as well
|
|
|
|
# yay -S -i {$pos} | grep URL | tail -1 | cut -d ':' -f2- | xargs xdg-open
|
2020-11-14 01:26:30 +00:00
|
|
|
}
|
2021-06-05 18:26:27 +00:00
|
|
|
# print -s adds a history entry
|
2020-10-23 12:00:41 +00:00
|
|
|
yas() {
|
2021-06-05 18:26:27 +00:00
|
|
|
preview_cache="$cache_dir/preview_{2}"
|
|
|
|
pkg=$(yzf S l -q "$1" "${@:2}" --preview "cat $preview_cache 2>/dev/null | grep -v 'Querying' | grep . || yay --color always -Si {2} | tee $preview_cache")
|
|
|
|
if test -n "$pkg"
|
|
|
|
then echo "Install $pkg..."
|
|
|
|
cmd="yay -S $pkg"
|
|
|
|
print -s "$cmd"
|
|
|
|
eval "$cmd"
|
|
|
|
fi
|
2020-10-23 12:00:41 +00:00
|
|
|
}
|
2020-11-14 01:26:30 +00:00
|
|
|
yar() {
|
2021-06-05 18:26:27 +00:00
|
|
|
pkg=$(yzf Q "" -q "$1" "${@:2}" --preview "yay --color always -Qli {1}")
|
|
|
|
if test -n "$pkg"
|
|
|
|
then echo "Removing $pkg..."
|
|
|
|
cmd="yay -R $pkg"
|
|
|
|
print -s "$cmd"
|
|
|
|
eval "$cmd"
|
|
|
|
fi
|
2020-11-14 01:26:30 +00:00
|
|
|
}
|
2020-10-12 20:20:06 +00:00
|
|
|
|