Skip to content

Instantly share code, notes, and snippets.

@quanon
Last active August 29, 2015 14:03
Show Gist options
  • Save quanon/afd7805e1e7c2ec7af49 to your computer and use it in GitHub Desktop.
Save quanon/afd7805e1e7c2ec7af49 to your computer and use it in GitHub Desktop.
peco でコマンド履歴を選択する
# peco
function peco-select-history () {
local tac
if which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
BUFFER=$(\history -n 1 | \
eval $tac | \
peco --query "$LBUFFER")
CURSOR=$#BUFFER # move cursor
zle -R -c # refresh
}
zle -N peco-select-history
bindkey '^R' peco-select-history
setopt hist_ignore_all_dups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment