From 2df665a53731efca390e6b1cc1959ff7302f0bf5 Mon Sep 17 00:00:00 2001 From: rootiest Date: Mon, 18 May 2026 21:17:13 -0400 Subject: [PATCH] feat(fzf): use fzf --fish integration and add fzf-update function - config.fish: add ~/.fzf/bin to PATH for git-installed fzf - config.fish: prefer fzf --fish | source (fzf >= 0.48, always version-matched) with fallback to integrations/fzf.fish for older builds; erase plugin bindings reliably when fzf is absent - functions/fzf-update.fish: install or upgrade fzf from git HEAD using --bin so shell config files are not modified --- config.fish | 28 +++++++++++++++++----------- functions/fzf-update.fish | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 functions/fzf-update.fish diff --git a/config.fish b/config.fish index 6f68631..2626333 100644 --- a/config.fish +++ b/config.fish @@ -75,6 +75,7 @@ fish_add_path $BUN_INSTALL/bin fish_add_path $XDG_DATA_HOME/npm-global/bin fish_add_path $HOME/.lmstudio/bin fish_add_path $HOME/.resend/bin +fish_add_path $HOME/.fzf/bin # ───────────────────────── CDPATH projects dir ────────────────────────── # Allows cd-ing to directories within $HOME/projects or $HOME without needing to specify the full path. @@ -111,17 +112,22 @@ if status is-interactive set -g fish_key_bindings fish_vi_key_bindings # ──────────────────────── Source FZF integration ──────────────────────── - # Sources the FZF integration script, which provides enhanced command history - # searching and file finding capabilities. - if test -f "$__fish_config_dir/integrations/fzf.fish" - source "$__fish_config_dir/integrations/fzf.fish" - end - - # ─────────────────── Remove fzf bindings when fzf is absent ───────────── - # conf.d/fzf.fish is managed by Fisher and may be restored on fisher update, - # so this is the reliable place to prevent fzf key bindings from being set - # on machines where fzf is not installed. - if not type -q fzf + # Prefer fzf's own fish integration (fzf --fish, available since fzf 0.48) + # which is always version-matched to the installed binary. Fall back to our + # bundled integrations/fzf.fish for older builds. + # Run `fzf-update` to install/upgrade fzf from git HEAD. + if type -q fzf + set -l _fzf_minor (fzf --version | string match -r '^\d+\.(\d+)')[2] + if test -n "$_fzf_minor" -a "$_fzf_minor" -ge 48 + fzf --fish | source + else + test -f "$__fish_config_dir/integrations/fzf.fish" + and source "$__fish_config_dir/integrations/fzf.fish" + end + else + # conf.d/fzf.fish is managed by Fisher and may be restored on fisher + # update, so this is the reliable place to strip its bindings when + # fzf is not installed. if functions -q _fzf_uninstall_bindings _fzf_uninstall_bindings end diff --git a/functions/fzf-update.fish b/functions/fzf-update.fish new file mode 100644 index 0000000..2f62708 --- /dev/null +++ b/functions/fzf-update.fish @@ -0,0 +1,15 @@ +# Copyright (C) 2026 Rootiest +# SPDX-License-Identifier: AGPL-3.0-or-later + +# Installs or upgrades fzf from git HEAD into ~/.fzf +function fzf-update --description 'Install or upgrade fzf from git HEAD' + if test -d ~/.fzf + echo "Updating fzf..." + git -C ~/.fzf pull --ff-only + else + echo "Installing fzf..." + git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf + end + and ~/.fzf/install --bin + and echo "fzf $(fzf --version) ready. Restart your shell to activate." +end