fzf: Fix fzf for paru and remove default preview

The `nl` preview was still stuck in the default fzf options for a while
and does not work with most things that it is intended for. Removing it
is vastly preferable to the half useless preview window on any fzf
invocation.
A true default preview window may either be possible through a separate
script looking for the right command to invoke, or for individual fzf
invocations which then simple use the correct commands in the first
place (see e.g. `fzfyay`, or `fzfyayrns`).

`fzfyay` and `fzfyayrns` now also respect paru if it is installed on the
system. They will default to yay and fall back to paru.
This commit is contained in:
Marty Oehme 2020-12-25 16:04:58 +01:00
parent ec3c5759f7
commit c4612a04c1
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 12 additions and 5 deletions

View file

@ -49,14 +49,21 @@ if exist fzf; then
# Fuzzy search packages to install
if exist yay; then
alias fzfyay="yay -Slq | fzf -m --preview 'yay -Si {1}' | xargs -ro yay -S"
# Fuzzy uninstall packages
alias fzfyayrns="yay -Qeq | fzf -m --preview 'yay -Qi {1}' | xargs -ro yay -Rns"
fzf_pkg_tool=yay
elif exist paru; then
fzf_pkg_tool=paru
fi
# shellcheck disable=2139 # we *want* this to be done at shell startup instead of dynamically
if [ -n "$fzf_pkg_tool" ]; then
alias fzfyay="$fzf_pkg_tool -Slq | fzf -m --preview '$fzf_pkg_tool -Si {1}' | xargs -ro $fzf_pkg_tool -S"
# Fuzzy uninstall packages
alias fzfyayrns="$fzf_pkg_tool -Qeq | fzf -m --preview '$fzf_pkg_tool -Qi {1}' | xargs -ro $fzf_pkg_tool -Rns"
fi
unset fzf_pkg_tool
# ripgrep-all to fzf search through any documents
if exist rga; then
rgafzf() {
fzfrga() {
RG_PREFIX="rga --files-with-matches"
xdg-open "$(
FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \

View file

@ -48,5 +48,5 @@ if [ "$(find /usr/share/terminfo -name "$TERMINAL*" | wc -l)" -eq 0 ] || [ -z "$
fi
if exist fzf; then
export FZF_DEFAULT_OPTS="--bind 'tab:toggle+down,shift-tab:toggle+up,ctrl-g:top,ctrl-t:toggle-preview,ctrl-d:preview-half-page-down,ctrl-u:preview-half-page-up' --color=light -1 -m --delimiter : --preview 'nl {1}' --preview-window +{2}-5"
export FZF_DEFAULT_OPTS="--bind 'tab:toggle+down,shift-tab:toggle+up,ctrl-g:top,ctrl-t:toggle-preview,ctrl-d:preview-half-page-down,ctrl-u:preview-half-page-up' --color=light -1 -m --delimiter :"
fi