Last active
November 24, 2017 18:26
-
-
Save chaudum/baa1f4981f30733e12acc21379cf3151 to your computer and use it in GitHub Desktop.
Key Bindings for fzy+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
# 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