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 ag 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
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"

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
  .zshrc.zwc
  dotfiles/zsh/.zshrc
  .oh-my-zsh/templates/zshrc.zsh-template
  .oh-my-zsh/plugins/redis-cli/_redis-cli
  .oh-my-zsh/themes/crcandy.zsh-theme
  .oh-my-zsh/plugins/react-native/README.md
  .oh-my-zsh/plugins/react-native/_react-native
  .oh-my-zsh/plugins/react-native/react-native.plugin.zsh
  .oh-my-zsh/plugins/arcanist/README.md
  .oh-my-zsh/plugins/archlinux/README.md
  .oh-my-zsh/plugins/rsync/rsync.plugin.zsh
  .oh-my-zsh/plugins/arcanist/arcanist.plugin.zsh
  .oh-my-zsh/plugins/archlinux/archlinux.plugin.zsh
  .oh-my-zsh/plugins/mercurial/README.md
  .oh-my-zsh/plugins/dircycle/dircycle.plugin.zsh
  .oh-my-zsh/plugins/mercurial/mercurial.plugin.zsh
  .oh-my-zsh/themes/tjkirch.zsh-theme
  .oh-my-zsh/plugins/ember-cli/README.md

Fuzzy directory go to

$ <alt> + c
$
> chrome
| 16635/70115
> Library/Caches/Google/Chrome
  Applications/Chrome Apps.localized
  Library/Caches/Google/Chrome/Default
  Applications/Chrome Canary Apps.localized
  Library/Application Support/Google/Chrome
  Library/Caches/Google/Chrome/Default/Cache
  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/Caches/Google/Chrome/PnaclTranslationCache
  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

Stanley Tan
@stnly