man fzf)Keybindings do not seem to working on my Mac running Catalina. I have installed fzf with the following steps:
brew update
brew install fzf
/usr/local/opt/fzf/install
source ~/.bashrc
But ** yields nothing, and none of the keybings (Ex. CTRL-T) do anything either. I have tried source-ing the .bashrc from .bash_profile with no luck either. For reference, those files look like the following:
bash-3.2$ cat ~/.bashrc
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
bash-3.2$ cat ~/.bash_profile
if [ -f $HOME/.bashrc ]; then
source $HOME/.bashrc
fi
I have tried this same process with zsh (And .zshrc respectively), but no luck.
Any ideas?
why not
cat ~/.fzf.bash and see what is there.
You don't need to source .bashrc in .bash_profile, it is a terrible practice. Please read the https://wiki.archlinux.org/index.php/Environment_variables 'defining variables' section (even if you're in macOS it is all the same) and learn what your shells are doing. When sourcing anything.
it is a terrible practice.
I disagree. It's a very common and practical solution for macOS users.
@varagnac You might be on to something, considering ~/.fzf.bash isn't even on my computer. What should it's contents be? And should it have been installed automatically by brew? I've searched through the issues and documentation and I can't find and references to the file.
@NoLookForcePush AFAIK that file should be created when you run /usr/local/opt/fzf/install.
FWIW (after following the installation instructions) I have a similar issue with **<Tab> not working on both bash-5.0.17 (Homebrew) as well as bash-3.2.57 (system). However, <Ctrl-T> works with both (after sourcing ~/.fzf.bash). And both **<Tab> and <Ctrl-T> do work on system zsh-5.7.1. I'm on macOS Catalina, although it feels like the issue may be the shell, not the OS.
My experience seems to be similar to this comment https://github.com/junegunn/fzf/issues/716#issuecomment-587164331, however I still can't get **<Tab> working even if I place
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
as the last line of ~/.bash_profile, so the solution doesn't seem to work.
EDIT I managed to isolate the code in my .bash_profile that was causing it to not work, although truthfully I really don't understand why. It's this snippet I put in to fix tmux meddling with $PATH (https://superuser.com/a/583502):
if [ -f /etc/profile ]; then~~
PATH=""
source /etc/profile
fi
Commenting out those lines solved the problem. (Although it probably leads to tmux issues again.) An alternative solution that doesn't involve commenting that out is to prepend Now looking forward to many more fuzzy searches 馃槂 $HOME/.fzf/bin to $PATH at the end of .bash_profile, which I'm going to go with for now.
Sorry, please ignore my additions; I can't reproduce it anymore. Think it was too late at night. Placing [ -f ~/.fzf.bash ] && source ~/.fzf.bash at the end of .bash_profile without any other $PATH meddling now works for me, so this is norepro. My apologies again and thank you for your work!
@yongrenjie Thanks so much for spending so much time looking into this! Unfortunately, it still doesn't work. My setup looks like:
~/.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# homebrew bash completion
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
~/.fzf.bash
# Setup fzf
# ---------
if [[ ! "$PATH" == */usr/local/opt/fzf/bin* ]]; then
export PATH="${PATH:+${PATH}:}/usr/local/opt/fzf/bin"
fi
# Auto-completion
# ---------------
[[ $- == *i* ]] && source "/usr/local/opt/fzf/shell/completion.bash" 2> /dev/null
# Key bindings
# ------------
source "/usr/local/opt/fzf/shell/key-bindings.bash"
~/.bashrc
# [ -f ~/.fzf.bash ] && source ~/.fzf.bash
You should be able to see the key bindings from the output of bind command like so:
$ bash --rcfile ~/.fzf.bash
bash-5.0$ bind -s
"\ec": " \C-b\C-k \C-u`__fzf_cd__`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d"
bash-5.0$ bind -X
"\C-r": "__fzf_history__"
"\C-t": "fzf-file-widget"
Unfortunately, none of these have helped. But I appreciate all the suggestions!
This worked
In my case the .fzf.zsh file had the keybinding disabled, I had to enable them:
source "/home/$(whoami)/.fzf/shell/key-bindings.zsh"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
or try this with bash
Also
Paste above line in vi ~/.zshrc file and don't forget to run this command afterward source ~/.zshrc
I was having same issue when I installed fzf with brew, install using git it will work for sure and
paste this [ -f ~/.fzf.bash ] && source ~/.fzf.bash
in your .bash_profile or zsh one.
First Uninstall fzf and then do this.
Use:
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf then
~/.fzf/install then
exit
Then close and reopen terminal and the commands should would work.
I can reproduce this 100% on Catalina
Installed fzf via homebrew
Manually ran /usr/local/Cellar/fzf/0.22.0/install script
Successfully created the ~/.fzf.bash and ~/.fzf.zsh files. Both are sourced in ~/.bashrc and ~/.zshrc
After opening and closing my terminal or manually sourcing the files, this still doesn't work.
My default bash is zsh and I have oh-my-zsh installed I wonder if this could be the root cause. Does anybody else has the same setup?
I switched to bash for troubleshooting completeness and the issue is still reproducible. Makes me think oh-my-zsh is not the culprit here.
I ran into this issue randomly yesterday after messing around in my zshrc file. I tracked it down to having set -o vi after I sourced ~/.fzf.zsh. I fixed it by sourcing ~/.fzf.zsh after setting vi mode. I also confirmed replacing both manual vi setting and manual sourcing of fzf with the vi-mode and fzf oh-my-zsh plugins work.
Most helpful comment
I disagree. It's a very common and practical solution for macOS users.