From c4612a04c1c9b712f4f7c7608426d9a4ae1adeb4 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 25 Dec 2020 16:04:58 +0100 Subject: [PATCH] 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. --- sh/.config/sh/alias | 15 +++++++++++---- sh/.config/sh/env | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sh/.config/sh/alias b/sh/.config/sh/alias index 0c5c140..8891ea5 100644 --- a/sh/.config/sh/alias +++ b/sh/.config/sh/alias @@ -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'" \ diff --git a/sh/.config/sh/env b/sh/.config/sh/env index d6ff82d..1b902a1 100644 --- a/sh/.config/sh/env +++ b/sh/.config/sh/env @@ -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