Fixing fzf Keybindings in Zsh
Problem #
You have fzf installed on your system:
fzf --version
# 0.60 (devel)
However, keybindings like Ctrl-R (history search), Ctrl-T (file completion), and Alt-C (directory change) do not work in Zsh.
Upon inspection:
ls -l ~/.fzf.zsh
# ls: cannot access '/home/user/.fzf.zsh': No such file or directory
And the system-installed binary is located at:
which fzf
# /usr/bin/fzf
Root cause:
- The APT (or system) version of
fzfoften only installs the binary, not the shell scripts needed for keybindings and completion. - Therefore, sourcing
~/.fzf.zshor/usr/share/fzf/installfails because the scripts are missing.
Solution #
Step 1: Remove the system fzf (optional but recommended) #
To avoid conflicts with the manual version:
sudo apt remove fzf
Step 2: Install fzf manually via Git #
Clone the official repository:
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
Run the installer with all options:
~/.fzf/install --all
What --all does:
- Enables keybindings (
Ctrl-R,Ctrl-T,Alt-C) - Enables fuzzy completion
- Updates your
~/.zshrcautomatically
Step 3: Reload Zsh #
After installation, restart your terminal or run:
source ~/.zshrc
Step 4: Test Keybindings #
Ctrl-R-> Search command historyCtrl-T-> Fuzzy file finderAlt-C-> Fuzzy change directory
They should now work immediately.
Notes #
- This method ensures you always have the latest
fzfversion and full functionality. - No conflicts with old system-installed binaries.
- If using
oh-my-zsh, make sure thefzfsource line is aftersource $ZSH/oh-my-zsh.shin~/.zshrc.