dotfiles/.config/shell/arch

37 lines
1.4 KiB
Plaintext
Raw Normal View History

which pacman >/dev/null || return 0
alias dragon='dragon-drag-and-drop'
# Arch aliases
alias pac='noglob sudo pacman'
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'
alias yayr='noglob yay -R'
yzf() {
query=$(test "$1" = "Q" && echo " -l")
2021-04-22 17:37:32 +00:00
sync=$(test "$1" = "S" && echo "true" || echo "")
pos=$(test "$query" && echo 1 || echo 2)
2021-05-27 20:04:26 +00:00
cache_dir="/tmp/yzf"
mkdir -p $cache_dir
list_cache="$cache_dir/list_$1$2"
preview_cache="$cache_dir/preview_{$pos}"
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") |
fzf --nth=$pos --multi --tiebreak=length --history=/var/tmp/fzf-history-yay \
--bind="double-click:execute(xdg-open 'https://archlinux.org/packages/{$pos}')" \
2021-05-27 20:04:26 +00:00
--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 |
2021-04-22 17:37:32 +00:00
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() {
2020-12-23 12:49:16 +00:00
pkg=$(yzf S l -q "$1" "${@:2}")
test "$pkg" && echo "Install $pkg..." && print -s "yay -S $pkg" && yay -S "$pkg"
}
yar() {
2020-12-23 12:49:16 +00:00
pkg=$(yzf Q "" -q "$1" "${@:2}")
test "$pkg" && echo "Removing $pkg..." && print -s "yay -R $pkg" && yay -R "$pkg"
}