Last active
August 23, 2016 10:20
-
-
Save stephanschubert/94ab20ec172589419a27 to your computer and use it in GitHub Desktop.
Reverse command history search with selecta's fuzzy matching for ZSH
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
| function exists { which $1 &> /dev/null } | |
| if exists selecta; then | |
| function selecta_select_history() { | |
| local tac | |
| exists gtac && tac="gtac" || { exists tac && tac="tac" || { tac="tail -r" } } | |
| BUFFER=$(fc -l -n 1 | eval $tac | selecta $LBUFFER) | |
| CURSOR=$#BUFFER # move cursor | |
| zle -R -c # refresh | |
| } | |
| zle -N selecta_select_history | |
| bindkey '^R' selecta_select_history | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment