Ben Berman
Ben Berman

Reputation: 379

Using fzf with tmux and zsh on Mac

I really like fzf when I use it, but it's difficult to actually use it. For example, I don't want to have to type vim $(fzf) every time I want to fuzzy find for a file. Ideally, I'd like to be able to just type ctrl-E to enter fzf and start editing the file after selecting it by pressing enter.

I don't know what keys are being pressed to accomplish what's done in the video on the github page (https://github.com/junegunn/fzf). Pressing tab just does normal auto-completion (and I don't want to do the ** style autocompletion. I want to enter fzf-tmux and have it paste the result into my command)

Can anyone help me?

Upvotes: 3

Views: 4038

Answers (1)

Junegunn Choi
Junegunn Choi

Reputation: 1641

The install script of fzf will setup such key bindings for you, CTRL-T, CTRL-R, and ALT-C. Refer to the the project home page for the details. The code for the key bindings can be found here.

If you do not like the default ones fzf provides, you can try writing your own.

# A simple widget for dictionary words
fzf-dict-widget() {
  LBUFFER="$LBUFFER$(cat /usr/share/dict/words | fzf-tmux -m | paste -sd" " -) "
  zle reset-prompt
}
bindkey '^E' fzf-dict-widget
zle     -N   fzf-dict-widget

Upvotes: 4

Related Questions