I'm using ZSH and am trying to integrate FZF into my config. It all works fine now, the only thing bothering me is that after searching for the command I want to run in FZF (e.g. a file/directory name) and pressing <ENTER> to close FZF, I have to press <ENTER> again to run the command.
Is there a way to run the command automatically after selecting an FZF result?
EDIT: Thanks to @svlasov I now have this solution:
export FZF_COMPLETION_TRIGGER=""
setopt vi # Removes the default FZF '<TAB>' keybinding
fzf-and-run-widget() {
fzf-completion
zle accept-line
}
zle -N fzf-and-run-widget
bindkey '^[^I' fzf-and-run-widget
Add to
.zshrc:fzf-history-widgetis part of fzf distribution, defined inkey-bindings.zsh. Replace with your own, if needed.zle accept-lineexecutes whatever is currently in ZSH prompt.'^R'is Ctrl-R. Change to something else, if needed.