fzf: Keyboard shortcuts don't work unless I explicitly `source ~/.bashrc`
- Category
- fzf binary
- fzf-tmux script
- Key bindings
- Completion
- Vim
- Neovim
- Etc.
- OS
- Linux
- Mac OS X
- Windows
- Etc.
- Shell
- bash
- zsh
- fish
I did
$ brew install fzf
==> Downloading https://homebrew.bintray.com/bottles/fzf-0.15.5.el_capitan.bottle.tar.gz
Already downloaded: /Users/pt/Library/Caches/Homebrew/fzf-0.15.5.el_capitan.bottle.tar.gz
==> Pouring fzf-0.15.5.el_capitan.bottle.tar.gz
==> Caveats
To install useful keybindings and fuzzy completion:
/usr/local/opt/fzf/install
To use fzf in Vim, add the following line to your .vimrc:
set rtp+=/usr/local/opt/fzf
==> Summary
🍺 /usr/local/Cellar/fzf/0.15.5: 17 files, 3.5M
$ /usr/local/opt/fzf/install
Downloading bin/fzf ...
- Already exists
- Checking fzf executable ... 0.15.5
Do you want to enable fuzzy auto-completion? ([y]/n)
Do you want to enable key bindings? ([y]/n)
Generate ~/.fzf.bash ... OK
Generate ~/.fzf.zsh ... OK
Do you want to update your shell configuration files? ([y]/n)
Update /Users/pt/.bashrc:
- [ -f ~/.fzf.bash ] && source ~/.fzf.bash
- Already exists: line #112
Update /Users/pt/.zshrc:
- [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
- Already exists: line #3
Finished. Restart your shell or reload config file.
source ~/.bashrc # bash
source ~/.zshrc # zsh
Use uninstall script to remove fzf.
For more information, see: https://github.com/junegunn/fzf
and then it works great in that window. If I reopen it thought, when I press CTRL + R it just puts
$ `__fzf_history__`
as my terminal. If I press Enter it works and brings up a list, but I select one I get:
$ `__fzf_history__`
-bash: !884: command not found
The same thing happens for CTRL + T.
If I type source ~/.bashrc in that same window, now everything works again. Is something you are doing expecting me to source bashrc instead of just doing whatever bash normally does?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 16 (6 by maintainers)
@MuschPusch I’m not sure what’s going on there. It seems like the bindings from fzf are overridden. Is there any
setcommand after the line that loads fzf script?Excerpt from https://github.com/junegunn/fzf#key-bindings-for-command-line
Does this help?
For anyone who comes here with a similar problem for zsh, I found that I needed to run the fzf scripts after the completion system initializes, and then it works. If I ran the fzf stuff first, neither the key bindings or the expansion worked.
Reading through the comments, I suspect different users are seeing slightly different problems, but anyway… (@MuschPusch I think we’re having the same issue.)
Arch Linux/Bash. Re-sourcing
~/.bashrcsometimes works for me - it’s not consistent for some reason. Key bindings always work if I’m logged into a virtual console.I normally have vi mode enabled - I set it in
~/.inputrc, not~/.bashrc. @junegunn asked if anysetcommands were made after sourcing fzf’s scripts - in my case there were not. I’m beginning to suspect Bash reads~/.inputrclast, preventingkey-bindings.bashfrom figuring out how to configure itself.If I also enable vi mode in my
~/.bashrc, any issues go away. (I still enable vi mode in my~/.inputrcfor other programs that use Readline.)In my case (MacOS 10.14.6 with bash 3.2.7) key bindings are not problematic, but expansion did not work until I changed the order as described by @jonbarksdale!
Relevant excerpt FROM my .bash_profile:
For clarity I tested with the [[ test ]] directly added to
.bash_profile(as opposed to being sourced from.bashrc). The result - naturally - is the same…!@junegunn asked if any
setcommands were made after sourcing fzf’s scripts - also in my case there were none of these.PS.: fzf = fantastic tool, I am so happy to have discovered it (!)
On OSX you typically need to source ~/.bashrc from ~/.bash_profile
http://apple.stackexchange.com/a/13019 http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup
No. If you start a new shell,
~/.bashrcis automatically loaded, so you don’t have to do it manually. Close your terminal emulator completely and restart it and see if it helps.