Skip to content

Instantly share code, notes, and snippets.

Created June 26, 2014 07:52
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/19bbb1eadf4f1c6bd761 to your computer and use it in GitHub Desktop.
Save anonymous/19bbb1eadf4f1c6bd761 to your computer and use it in GitHub Desktop.
pecoで履歴からマッチするキーワードをその場に補完
function in_place_history_keyword_completion() {
pos=CURSOR # 現在のカーソル位置を取得
selected=$(history -10000 | cut -d' ' -f3- | tr '|' ' ' | tr ' ' '\n' | sort -u | peco) # 選択した結果
BUFFER="${BUFFER[1,$pos]}${selected}${BUFFER[$pos,-1]}"
CURSOR=$#BUFFER # move cursor
zle -R -c # refresh
}
zle -N in_place_history_keyword_completion
bindkey '^R' in_place_history_keyword_completion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment