Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Jessidhia/2a40539515bbdcb4c86f0b1e4282cde2 to your computer and use it in GitHub Desktop.
Save Jessidhia/2a40539515bbdcb4c86f0b1e4282cde2 to your computer and use it in GitHub Desktop.
Use peco (https://github.com/peco/peco) to search ZSH's history via ctrl+R
# Search shell history with peco: https://github.com/peco/peco
# Adapted from: https://github.com/mooz/percol#zsh-history-search
if [ "$(which peco &>/dev/null && echo 'a' | peco --select-1)" = 'a' ]; then
function peco_select_history() {
local lbuf="$LBUFFER"
BUFFER=
zle -c -U "$(print -rl - $history | peco --layout=bottom-up --query "$lbuf")"
}
zle -N peco_select_history
bindkey '^R' peco_select_history
fi
@Jessidhia
Copy link
Author

Made to work with zsh 5.2 (zle -l can't be used in zle widgets)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment