fzf and rg

Everyone who works in the shell needs a faster way to get around. fzf and rg in zsh makes for a great combination. I’ve been using this setup for a while now and it allows me to jump around my filesystem.

$ brew install fzf rg

To install useful key bindings and fuzzy completion:

$ $(brew --prefix)/opt/fzf/install

Adding a couple of lines to .zshrc

# Setting rg as the default source for fzf
export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow -g "!{.git,node_modules}/*" 2> /dev/null'

# To apply the command to CTRL-T as well

And we’re done!

Fuzzy history search

$ <crtl> + r
   7063  bundle
   7064  bundle exec middleman build
   7065  time bundle exec middleman build
   7066  bundle install
   7067  bundle purge
   7068  bundle --help
   7069  bundle clean
   7070  bundle clean --force
   7071  bundle exec middleman server
   7115  bundle exec middleman
   7161  bundle exec middleman version
   7186  bundle exec middleman server
   7196  bundle install
   7197  bundle exec middleman server
   7265  bundle install
   7266  bundle update
   7267  gem install bundler --pre
   7269  bundle exec middleman build
>  7409  bundle exec middleman server
  129/7409 +S
> bundle

Fuzzy file search

$ <ctrl> + t
> zshrc
\ 1678/972367
> .zshrc

Fuzzy directory go to

$ <alt> + c
> chrome
| 16635/70115
> Library/Caches/Google/Chrome
  Applications/Chrome Apps.localized
  Applications/Chrome Canary Apps.localized
  Library/Application Support/Google/Chrome
  Library/Application Support/Google/Chrome/pnacl
  Library/Application Support/Google/Chrome Canary
  Library/Caches/Google/Chrome/Default/Media Cache
  Library/Application Support/Google/Chrome/Default
  Library/Application Support/Google/Chrome/Crashpad
  Library/Application Support/Google/Chrome/EVWhitelist
  Library/Application Support/Google/Chrome/PepperFlash
  Library/Application Support/Google/Chrome/ShaderCache
  Library/Application Support/Google/Chrome/WidevineCDM
  Applications/Chrome Canary Apps.localized/app_list.app
  Library/Application Support/Google/Chrome/Crashpad/new
  Library/Application Support/Google/Chrome/OriginTrials