mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-19 17:13:42 -05:00
add yay helpers
52
Examples.md
52
Examples.md
@@ -18,7 +18,7 @@ Table of Contents
|
|||||||
* [man pages](#man-pages)
|
* [man pages](#man-pages)
|
||||||
* Package management
|
* Package management
|
||||||
* [apt](#apt)
|
* [apt](#apt)
|
||||||
* [Pacman](#pacman)
|
* [Pacman/Yay](#pacman)
|
||||||
* [NPM](#npm)
|
* [NPM](#npm)
|
||||||
* [Homebrew](#homebrew)
|
* [Homebrew](#homebrew)
|
||||||
* [Homebrew Cask](#homebrew-cask)
|
* [Homebrew Cask](#homebrew-cask)
|
||||||
@@ -1786,15 +1786,59 @@ bindkey '^o' pick_torrent
|
|||||||
function in() {
|
function in() {
|
||||||
yay -Slq | fzf -q "$1" -m --preview 'yay -Si {1}'| xargs -ro yay -S
|
yay -Slq | fzf -q "$1" -m --preview 'yay -Si {1}'| xargs -ro yay -S
|
||||||
}
|
}
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Remove installed packages (change to pacman/AUR helper of your choice)
|
# Remove installed packages (change to pacman/AUR helper of your choice)
|
||||||
function re() {
|
function re() {
|
||||||
yay -Qq | fzf -q "$1" -m --preview 'yay -Qi {1}' | xargs -ro yay -Rns
|
yay -Qq | fzf -q "$1" -m --preview 'yay -Qi {1}' | xargs -ro yay -Rns
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Shows version & repository, elaborate preview, bindings to show package in web, caches AUR packages list:
|
||||||
|
```sh
|
||||||
|
# Helper function to integrate yay and fzf
|
||||||
|
yzf() {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
# Dev note: print -s adds a shell history entry
|
||||||
|
|
||||||
|
# List installable packages into fzf and install selection
|
||||||
|
yas() {
|
||||||
|
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$@") |
|
||||||
|
yzf 2 --tiebreak=index --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 "Installing $pkg..."
|
||||||
|
cmd="yay -S $pkg"
|
||||||
|
print -s "$cmd"
|
||||||
|
eval "$cmd"
|
||||||
|
rehash
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
# List installed packages into fzf and remove selection
|
||||||
|
# Tip: use -e to list only explicitly installed packages
|
||||||
|
yar() {
|
||||||
|
pkg=$(yay --color=always -Q "$@" | yzf 1 --tiebreak=length --preview="yay --color always -Qli {1}")
|
||||||
|
if test -n "$pkg"
|
||||||
|
then echo "Removing $pkg..."
|
||||||
|
cmd="yay -R --cascade --recursive $pkg"
|
||||||
|
print -s "$cmd"
|
||||||
|
eval "$cmd"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
### Clipboard
|
### Clipboard
|
||||||
Uses [wl-copy](https://github.com/bugaevc/wl-clipboard) to copy the current entry to the clipboard on Wayland:
|
Uses [wl-copy](https://github.com/bugaevc/wl-clipboard) to copy the current entry to the clipboard on Wayland:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user