Skip to content

Instantly share code, notes, and snippets.

@ay65535
Created April 3, 2015 17:51
Show Gist options
  • Save ay65535/1b4f73ffd029f51a9959 to your computer and use it in GitHub Desktop.
Save ay65535/1b4f73ffd029f51a9959 to your computer and use it in GitHub Desktop.
peco-select-history 複数行のコマンドにも対応版
function peco-select-history() {
local buffer
local sep='¶'
buffer=$(
history -nr $'\n'=$sep 1 | \
peco --layout=bottom-up --query "$LBUFFER" | \
sed s/$sep/\\$'\n'/g)
if [[ ! -z buffer ]]; then
BUFFER=$buffer
fi
CURSOR=$#BUFFER
zle redisplay
}
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