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
This commit is contained in:
+16
-10
@@ -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"
|
||||
# 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
|
||||
|
||||
# ─────────────────── 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
|
||||
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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user