Skip to content

Instantly share code, notes, and snippets.

@ichizok
Last active February 15, 2017 05:59
Show Gist options
  • Select an option

  • Save ichizok/896e32bc1331cabf5106ca6256ed95cf to your computer and use it in GitHub Desktop.

Select an option

Save ichizok/896e32bc1331cabf5106ca6256ed95cf to your computer and use it in GitHub Desktop.
zsh select history by peco
## select-history by peco
if type peco &>/dev/null; then
if type tac &>/dev/null; then
function _reverse_lines() { tac }
else
function _reverse_lines() { tail -r }
fi
function peco-select-history() {
BUFFER=$(history -n 1 | _reverse_lines | peco --query "${LBUFFER}")
CURSOR=${#BUFFER}
zle clear-screen
}
zle -N peco-select-history
bindkey '^r' peco-select-history
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment