Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Use peco ( to search ZSH's history via ctrl+R
# Search shell history with peco:
# Adapted from:
if which peco &> /dev/null; then
function peco_select_history() {
local tac
(which gtac &> /dev/null && tac="gtac") || \
(which tac &> /dev/null && tac="tac") || \
tac="tail -r"
BUFFER=$(fc -l -n 1 | eval $tac | \
peco --layout=bottom-up --query "$LBUFFER")
CURSOR=$#BUFFER # move cursor
zle -R -c # refresh
zle -N peco_select_history
bindkey '^R' peco_select_history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.