Last active
August 29, 2015 14:02
-
-
Save iorionda/e7398d30b7074c54bbeb to your computer and use it in GitHub Desktop.
select command from zsh history
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
| ################################################################################ | |
| # peco | |
| ################################################################################ | |
| function peco-select-history() { | |
| local tac | |
| if which tac > /dev/null; then | |
| tac="tac" | |
| else | |
| tac="tail -r" | |
| fi | |
| BUFFER=$(history | \ | |
| awk '{ $1="";print }' | \ | |
| eval $tac | \ | |
| peco --query "$LBUFFER") | |
| CURSOR=$#BUFFER | |
| zle clear-screen | |
| } | |
| 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