Skip to content

Instantly share code, notes, and snippets.

@Genki-S
Created January 19, 2014 08:29
Show Gist options
  • Save Genki-S/8501974 to your computer and use it in GitHub Desktop.
Save Genki-S/8501974 to your computer and use it in GitHub Desktop.
function exists { which $1 &> /dev/null }
if exists percol; then
function percol_select_history() {
local tac
exists gtac && tac="gtac" || { exists tac && tac="tac" || { tac="tail -r" } }
BUFFER=$(fc -l -n 1 | eval $tac | percol --query "$LBUFFER")
CURSOR=$#BUFFER # move cursor
zle -R -c # refresh
}
zle -N percol_select_history
bindkey '^R' percol_select_history
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment