Last active
August 29, 2015 14:05
-
-
Save jeebak/e13c209da18ef5981792 to your computer and use it in GitHub Desktop.
Zsh history-search-backward widget, for fzf
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
# https://gist.github.com/jeebak/e13c209da18ef5981792 | |
# Derived from fzf-history-widget() that's provided by: | |
# | |
# https://github.com/junegunn/fzf | |
fzf-history-search-backward() { | |
local buffer="$BUFFER" | |
buffer="${buffer#"${buffer%%[![:space:]]*}"}" | |
buffer="${buffer%"${buffer##*[![:space:]]}"}" | |
# http://unix.stackexchange.com/a/11941 | |
LBUFFER=$(fc -l 1 | sed "s/ *[0-9*]* *//" | awk '!seen[$0]++' | grep "^$buffer" | fzf +s +m -n2..,..) | |
zle redisplay | |
} | |
zle -N fzf-history-search-backward | |
bindkey '\ep' fzf-history-search-backward |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment