Skip to content

Instantly share code, notes, and snippets.

@chaudum
Last active November 24, 2017 18:26
Show Gist options
  • Save chaudum/baa1f4981f30733e12acc21379cf3151 to your computer and use it in GitHub Desktop.
Save chaudum/baa1f4981f30733e12acc21379cf3151 to your computer and use it in GitHub Desktop.
Key Bindings for fzy+zsh
# Key bindings for fzy
# https://github.com/jhawthorn/fzy
#
# Installation:
# Place this file e.g. in ~/.fzy/ and add "source ~/.fzy/key-bindings.zsh" to your .zshrc
if [[ $- == *i* ]]; then
__fzycmd() {
echo "fzy"
}
# CTRL-R - Paste the selected command from history into the command line
fzy-history-widget() {
local selected num
selected=( $(fc -l 1 | $(__fzycmd) -s -q "${LBUFFER//$/\\$}") )
if [ -n "$selected" ]; then
num=$selected[1]
if [ -n "$num" ]; then
zle vi-fetch-history -n $num
fi
fi
zle redisplay
}
zle -N fzy-history-widget
bindkey '^R' fzy-history-widget
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment