2020-10-14 12:16:36 +00:00
|
|
|
which pacman >/dev/null || return 0
|
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'
|
2021-06-18 16:05:51 +00:00
|
|
|
alias pacr='pac -R --recursive'
|
2021-12-23 19:04:26 +00:00
|
|
|
alias yau='sudo systemctl start --show-transaction reflector && noglob yay'
|
2022-01-09 21:17:18 +00:00
|
|
|
alias yays='noglob yay -Sy --needed --noprovides'
|
2021-06-18 16:05:51 +00:00
|
|
|
alias yayr='noglob yay -R --cascade --recursive'
|
2020-11-14 01:26:30 +00:00
|
|
|
|
2022-01-09 21:17:18 +00:00
|
|
|
_yayre_params="-S --rebuild --noprovides --nodiffmenu --noconfirm"
|
|
|
|
# Reinstall given packages with all dependencies - https://www.reddit.com/r/archlinux/comments/33cety
|
|
|
|
yayre() {
|
|
|
|
yay $(echo $_yayre_params) --asdeps $(yay -Si "$@" | grep Depends | cut -d':' -f2) &&
|
|
|
|
yay $(echo $_yayre_params) "$@"
|
|
|
|
}
|
|
|
|
|
2021-09-29 16:38:57 +00:00
|
|
|
# Helper function to integrate yay and fzf
|
2020-11-14 01:26:30 +00:00
|
|
|
yzf() {
|
2021-12-10 15:01:21 +00:00
|
|
|
pos=$1
|
|
|
|
shift
|
|
|
|
sed "s/ /\t/g" |
|
|
|
|
fzf --nth=$pos --multi --history="${FZF_HISTDIR:-$XDG_STATE_HOME/fzf}/history-yzf$pos" \
|
|
|
|
--preview-window=60%,border-left \
|
|
|
|
--bind="double-click:execute(xdg-open 'https://archlinux.org/packages/{$pos}'),alt-enter:execute(xdg-open 'https://aur.archlinux.org/packages?K={$pos}&SB=p&SO=d&PP=100')" \
|
|
|
|
"$@" | cut -f$pos | xargs
|
2020-11-14 01:26:30 +00:00
|
|
|
}
|
2021-06-06 16:35:43 +00:00
|
|
|
|
2021-09-29 16:38:57 +00:00
|
|
|
# Dev note: print -s adds a shell history entry
|
|
|
|
|
|
|
|
# List installable packages into fzf and install selection
|
2020-10-23 12:00:41 +00:00
|
|
|
yas() {
|
2021-12-10 15:01:21 +00:00
|
|
|
cache_dir="/tmp/yas-$USER"
|
|
|
|
test "$1" = "-y" && rm -rf "$cache_dir" && shift
|
|
|
|
mkdir -p "$cache_dir"
|
|
|
|
preview_cache="$cache_dir/preview_{2}"
|
|
|
|
list_cache="$cache_dir/list$*"
|
|
|
|
{ test "$(cat "$list_cache" | wc -l)" -lt 50000 && rm "$list_cache"; } 2>/dev/null
|
|
|
|
pkg=$(
|
|
|
|
( cat "$list_cache" 2>/dev/null ||
|
|
|
|
{ pacman --color=always -Sl "$@"; yay --color=always -Sl aur "$@" } |
|
|
|
|
sed 's/ [^ ]*unknown-version[^ ]*//' | tee "$list_cache" ) |
|
2022-08-28 20:34:44 +00:00
|
|
|
yzf 2 --tiebreak=chunk,index --preview="cat $preview_cache 2>/dev/null | grep -v 'Querying' | grep . || yay --color always -Si {2} | tee $preview_cache"
|
2021-12-10 15:01:21 +00:00
|
|
|
)
|
|
|
|
if test -n "$pkg"
|
|
|
|
then echo "Installing $pkg..."
|
2022-01-05 17:40:29 +00:00
|
|
|
cmd="yay -Sy --rebuild $pkg"
|
2021-12-10 15:01:21 +00:00
|
|
|
print -s "$cmd"
|
2021-12-20 17:34:03 +00:00
|
|
|
eval "$cmd"
|
2021-12-10 15:01:21 +00:00
|
|
|
rehash
|
|
|
|
fi
|
2020-10-23 12:00:41 +00:00
|
|
|
}
|
2021-09-29 16:38:57 +00:00
|
|
|
# List installed packages into fzf and remove selection
|
|
|
|
# Tip: use -e to list only explicitly installed packages
|
2020-11-14 01:26:30 +00:00
|
|
|
yar() {
|
2022-08-28 20:34:44 +00:00
|
|
|
pkg=$(yay --color=always -Q "$@" | yzf 1 --tiebreak=chunk,length --preview="yay --color always -Qli {1} | sed 's/^[^a-z]*m{1}//'")
|
2021-12-10 15:01:21 +00:00
|
|
|
if test -n "$pkg"
|
|
|
|
then echo "Removing $pkg..."
|
|
|
|
cmd="yay -R --cascade --recursive $pkg"
|
|
|
|
print -s "$cmd"
|
|
|
|
eval "$cmd"
|
|
|
|
fi
|
2020-11-14 01:26:30 +00:00
|
|
|
}
|
2020-10-12 20:20:06 +00:00
|
|
|
|