Last active
February 15, 2017 05:59
-
-
Save ichizok/896e32bc1331cabf5106ca6256ed95cf to your computer and use it in GitHub Desktop.
zsh select history by peco
This file contains hidden or 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
| ## select-history by peco | |
| if type peco &>/dev/null; then | |
| if type tac &>/dev/null; then | |
| function _reverse_lines() { tac } | |
| else | |
| function _reverse_lines() { tail -r } | |
| fi | |
| function peco-select-history() { | |
| BUFFER=$(history -n 1 | _reverse_lines | peco --query "${LBUFFER}") | |
| CURSOR=${#BUFFER} | |
| zle clear-screen | |
| } | |
| zle -N peco-select-history | |
| bindkey '^r' peco-select-history | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment