Skip to content

Instantly share code, notes, and snippets.

@jeebak
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeebak/e13c209da18ef5981792 to your computer and use it in GitHub Desktop.
Save jeebak/e13c209da18ef5981792 to your computer and use it in GitHub Desktop.
Zsh history-search-backward widget, for fzf
# 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