Created
June 26, 2014 07:52
-
-
Save anonymous/19bbb1eadf4f1c6bd761 to your computer and use it in GitHub Desktop.
pecoで履歴からマッチするキーワードをその場に補完
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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