Closed dboneham closed 6 years ago
Following upgrade to Ubuntu 18.04 and reinstallation of software inclung FZF. Ctrl+r does not work for me in zsh, although it does if I switch back to bash. I have reinstalled fzf a couple of times without changing this. Any ideas?
For me FZF does not work on Vagrant ZSH shell.
fzf adds completion files for your shells like ~/.fzf.bash
, ~/.fzf.zsh
and loads them by configuring corresponding rc file. For example, it will add
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
in ~/.bashrc
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
in ~/.zshrc
I think in ur case, ur missing these lines in ur .zshrc
file or the completion files as missing.
u may run the install script again to add the bindings & completions for ur shells
I hope that helps
Thanks Rajesh.
However, this not the answer as the Alt-C and Ctrl-T bindings work correctly in zsh.
I did reinstall fzf just to make sure, but the Ctrl-R binding (and only that binding) continues not to work. This suggests to me that something in the Ctrl-R part of the zsh binding script is not quite right - but I cannot identfiy any error.
Best wishes
On 2 June 2018 at 14:23, Rajesh Sharma notifications@github.com wrote:
fzf adds completion files for your shells like ~/.fzf.bash, ~/.fzf.zsh and loads them by configuring corresponding rc file. For example, it will add
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
in ~/.bashrc
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
in ~/.zshrc
I think in ur case, ur missing these lines in ur .zshrc file or the completion files as missing.
u may run the install script again to add the bindings & completions for ur shells
I hope that helps
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/junegunn/fzf/issues/1304#issuecomment-394087351, or mute the thread https://github.com/notifications/unsubscribe-auth/AYia7mwWL-PrEAHLfKvkJKCncuw_TLTzks5t4pHTgaJpZM4UNur1 .
@dboneham its possible that the key was bound to something else ( for example in ur zshrc or via another plugin ). Can u check like this
bindkey | grep fzf
u should get something like this in result:
"^I" fzf-completion
"^R" fzf-history-widget
"^T" fzf-file-widget
"^[c" fzf-cd-widget
Rajesh
This is what I get.
"^T" fzf-file-widget "^[c" fzf-cd-widget
I inspected the bindkey results and Ctrl-R is bound to history-incremental-search-backward.
Ctrl-I is bound to expand-or-complete-with-dots.
No clue as what is bringing about these bindings. I suspect it may be my zshrc, which I copy below.
########## oh-my-zsh ###########
1 export ZSH=/home/dboneham/.oh-my-zsh 2 HYPHEN_INSENSITIVE="true" 3 export UPDATE_ZSH_DAYS=3 4 ENABLE_CORRECTION="true" 5 COMPLETION_WAITING_DOTS="true" 6 HIST_STAMPS="mm/dd/yyyy" 7 export SSH_KEY_PATH="~/.ssh/rsa_id" 8 9 10 ########## custom zshrc ########### 11 if [[ $(tty) = "/dev/tty1" ]]; then 12 pgrep i3 || startx 13 fi 14 15 export PATH=$HOME/bin:/usr/local/bin:$PATH 16 export BROWSER="google-chrome" 17 export BROWSERCLI="w3m" 18 export IMAGEVIEWER="feh" 19 export PLAYER="mpv" 20 export TERMINAL="urxvt" 21 export PAGER="w3m" 22 export EDITOR="vim" 23 export RANGER_LOAD_DEFAULT_RC="false" 24 export PODPLAYER="mplayer" 25 26 source ~/.aliases 27 . /usr/share/powerline/bindings/zsh/powerline.zsh 28 [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh 29 source "${HOME}/.zgen/zgen.zsh" 30 31 if ! zgen saved; then 32 33 # specify plugins here 34 zgen oh-my-zsh 35 zgen oh-my-zsh plugins/git 36 zgen oh-my-zsh plugins/sudo 37 zgen oh-my-zsh plugins/command-not-found 38 zgen oh-my-zsh plugins/extract 39 zgen oh-my-zsh plugins/pip 40 zgen oh-my-zsh plugins/web-search 41 zgen oh-my-zsh plugins/z 42 zgen oh-my-zsh themes/agnoster 43 zgen load urbainvaes/fzf-marks 44 zgen load zsh-users/zsh-completions src 45 46 # generate the init script from plugins above 47 echo "Creating a zgen save" 48 zgen save 49 fi 50 51 powerline-daemon -q 52 53 eval "$(fasd --init auto)" 54
On 3 June 2018 at 16:51, Rajesh Sharma notifications@github.com wrote:
@dboneham https://github.com/dboneham its possible that the key was bound to something else. Can u check like this
bindkey | grep fzf
u should get something like this in result:
"^I" fzf-completion "^R" fzf-history-widget "^T" fzf-file-widget "^[c" fzf-cd-widget
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/junegunn/fzf/issues/1304#issuecomment-394171410, or mute the thread https://github.com/notifications/unsubscribe-auth/AYia7nGtrj-uL7cqgYuVRJNug5W5szw-ks5t5AYNgaJpZM4UNur1 .
You could try moving [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
to the end, or just add the binding to different key to see if that works. One of ur plugins might have overwritten fzf bindings for "^R"
Thanks.
The solution was indeed just to bind Ctrl-R to fzf-history-widget I noticed that an alternative binding for history-incremental-search-backwards was already in existence, so no loss of functionality. Not that I sue that functio anyway..Inbox
My guess is that the zsh completion plugin overwrite the binding. So I have just reversed that. I may need to figure out a way of making my binding permanent if it overwrites again
On 4 June 2018 at 11:18, Rajesh Sharma notifications@github.com wrote:
You could try moving [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh to the end, or just add the binding to different key to see if that works. One of ur plugins might have overwritten fzf bindings for "^R"
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/junegunn/fzf/issues/1304#issuecomment-394305636, or mute the thread https://github.com/notifications/unsubscribe-auth/AYia7g4p1wR76ALpVqp9Cp5_5GyruifQks5t5Ql3gaJpZM4UNur1 .
Fixed it permanently by adding a line to my zshrc at the end binding the key to the fzf widget.
Thanks again
On 4 June 2018 at 12:03, David Boneham dboneham@boneham.org.uk wrote:
Thanks.
The solution was indeed just to bind Ctrl-R to fzf-history-widget I noticed that an alternative binding for history-incremental-search-backwards was already in existence, so no loss of functionality. Not that I sue that functio anyway..Inbox
My guess is that the zsh completion plugin overwrite the binding. So I have just reversed that. I may need to figure out a way of making my binding permanent if it overwrites again
On 4 June 2018 at 11:18, Rajesh Sharma notifications@github.com wrote:
You could try moving [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh to the end, or just add the binding to different key to see if that works. One of ur plugins might have overwritten fzf bindings for "^R"
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/junegunn/fzf/issues/1304#issuecomment-394305636, or mute the thread https://github.com/notifications/unsubscribe-auth/AYia7g4p1wR76ALpVqp9Cp5_5GyruifQks5t5Ql3gaJpZM4UNur1 .
glad it worked out. Can u close this issues. Thanks
Just remove
\C-y\ey
part from the bind command in the ~/.fzf/shell/key-bindings.bash:
bind '"\C-r": " \C-e\C-u\C-y\ey\C-u`__fzf_history__`\e\C-e\er\e^"'
and it works like a charm.
I found bindkey -e
binds "^R" to history-incremental-search-backward. The key binding order matters.
I have a question about this topic too.
I install fzf through Homebrew and I add fzf in zshrc.zsh plugin like this plugins=(fzf)
I saw the suggestion is to put [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
in the end of zshrc.zsh. But I don't have any .fzf repo in my home directory. So this suggestion is not suit for me. I also saw some tutorial is git clone fzf
repo in home directory as .fzf
I have 2 questions.
Can I just use oh-my-zsh plugins fzf or the Homebrew installed one? Because I don't want to have same fzf repo in everywhere.
If first question is No. Is any way to solve my problem or the only way is clone a repo in home directory?
Thanks for reply
Reply my question. Install fzf using Homebrew like
# To install useful key bindings and fuzzy completion:
$(brew --prefix)/opt/fzf/install
It add .fzf.zsh
and .fzf.bash
in home directory so now it can be sourced
In my case the .fzf.zsh
file had the keybinding disabled, I had to enable them:
# Key bindings
# ------------
source "/home/user/.fzf/shell/key-bindings.zsh
then you can try: source ~/.fzf.zsh
(or bash)
In my case the
.fzf.zsh
file had the keybinding disabled, I had to enable them:# Key bindings # ------------ source "/home/user/.fzf/shell/key-bindings.zsh
then you can try:
source ~/.fzf.zsh
(or bash)
In my case too, after a fresh install of ubuntu, I faced the same issue, at pressing "ctrl+r" was bck-i-search: opening. Luckily it worked.
source "/home/$(whoami)/.fzf/shell/key-bindings.zsh" [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh Paste above line in 'vi ~/.zshrc' file and don't forget to run this command afterwards 'source ~/.zshrc'
If you are trying to install for the raspberry pi, key bindings are not installed automatically!
Add this to .zshrc: source /usr/share/doc/fzf/examples/key-bindings.zsh
You can see this yourslf:
apt-cache show fzf
...
Refer /usr/share/doc/fzf/README.Debian for quick instructions on how to
add keybindings for Bash, Zsh, Fish to call fzf.
cat /usr/share/doc/fzf/README.Debian
...
Zsh
===
Append this line to ~/.zshrc to enable fzf keybindings for Zsh:
source /usr/share/doc/fzf/examples/key-bindings.zsh
EDIT: woops, scratch that. I'm on the wrong repo! :D sorry guys I thought this was zsh's bug tracker.
old comment below:
I have this same issue, and the offender is unexpected, but probably similar to OP:
export EDITOR=vim
export VISUAL=vim
Once I removed those lines, CTRL-r started working again, out of the box.
Is this intentional?
In my case the problem was that I used sudo
when installing and it was making config files in /root
instead of home directory
For those coming here after an upgrade to OSX Mojave: for whatever reason, history stopped writing to .zhistory
but .zsh_history
. cp .zhistory .zsh_history
to recover from your amnesia.
I also had to restart iTerm, source .zshrc
did not rebuild the ctrl+r list.
This worked for me
nano ~/.zshrc
changed from plugins=(zsh-autosuggestions zsh-syntax-highlighting)
to plugins=(zsh-autosuggestions zsh-syntax-highlighting fzf)
In my case,
source /usr/local/share/zsh-vi-mode/zsh-vi-mode.zsh
in ~/.zshrc
was blocking CTRL+R
For my situation, even after reinstalling fzf with homebrew brew reinstall fzf
, making sure i hit yes on all the options, the simple solution was to run source ~/.zshrc
to refresh the changes
In my case,
source /usr/local/share/zsh-vi-mode/zsh-vi-mode.zsh
in
~/.zshrc
was blockingCTRL+R
I had pretty much the same issue - I was using the vi-mode
plugin with oh-my-zsh and to solve the issue I just commented out line 114 (bindkey '^r' history-incremental-search-backward
) from ~/.oh-my-zsh/plugins/vi-mode/vi-mode.plugin.zsh
and then source ~/.zshrc
And now my CTRL-R
works again.
In my case,
source /usr/local/share/zsh-vi-mode/zsh-vi-mode.zsh
in
~/.zshrc
was blockingCTRL+R
Thanks for pointing me in the right direction, I spent like 3 freaking hours trying to figure this out.
The zsh-vi-mode folks have the solution in their documentation, which is basically sourcing the .fzf.zsh
file after zsh-vi-mode initializes. This is how my .zshrc section looks for the zsh-vi-mode. The key part is the zvm_after_init_commands
one
# Source zsh-vi-mode plugin, if it exists
if [ -f "/opt/homebrew/opt/zsh-vi-mode/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh" ]; then
source /opt/homebrew/opt/zsh-vi-mode/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
# Following 4 lines modify the escape key to `kj`
ZVM_VI_ESCAPE_BINDKEY=kj
ZVM_VI_INSERT_ESCAPE_BINDKEY=$ZVM_VI_ESCAPE_BINDKEY
ZVM_VI_VISUAL_ESCAPE_BINDKEY=$ZVM_VI_ESCAPE_BINDKEY
ZVM_VI_OPPEND_ESCAPE_BINDKEY=$ZVM_VI_ESCAPE_BINDKEY
# Source .fzf.zsh so that the ctrl+r bindkey is given back fzf
zvm_after_init_commands+=('[ -f $HOME/.fzf.zsh ] && source $HOME/.fzf.zsh')
fi
The answer is simply to use this line:
zvm_after_init_commands+=('[ -f $HOME/.fzf.zsh ] && source $HOME/.fzf.zsh')
It seems to work whether you put it above or below the vi-mode source. But I think it makes more sense to put it before.
I was confused by the answer above's large code block, so I'm just clarifying.