Superpowering history_search in the shell


In the last few days I read a lot about fzf and how it allows the user to fuzzy-find everything. Even though all those fancy blog posts stir my geeky side, I decided to bring some attention to peco and how I superpower my linux setup with this handy tool.

What is peco?

Peco is a simple Go executable that can be downloaded from the offical releases page at and dropped in the $PATH.

Let’s define a custom keybinding for the shell using peco to search my command history. I’m a big fan of fish and the following snippet defines a custom keybinding on Ctrl-r:

function fish_user_key_bindings
    bind \cr 'peco_select_history (commandline -b)'

The function peco_select_history is defined as follows:

function peco_select_history
  if test (count $argv) = 0
    set peco_flags --layout=bottom-up
    set peco_flags --layout=top-down --query "$argv"

  history|peco $peco_flags|read foo

  if [ $foo ]
    commandline $foo
    commandline ''

Now whenever I press Ctrl-r, I have a lightning fast, super easy to use and powerful search for my shell.

Update: The video is a bit too big for my blog layout. Just watch it in fullscreen to see me switching between search modes.