Created
August 15, 2019 23:56
-
-
Save EgZvor/b237a9c324f8fd5b15480ed61d1dff67 to your computer and use it in GitHub Desktop.
fzy bindings for zsh mirrored from fzf and simplified
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
# CTRL-T - Paste the selected file path(s) into the command line | |
__fsel() { | |
setopt localoptions pipefail 2> /dev/null | |
rg --files --hidden --glob '!.git/' | fzy | |
local ret=$? | |
echo | |
return $ret | |
} | |
fzy-file-widget() { | |
LBUFFER="${LBUFFER}$(__fsel)" | |
local ret=$? | |
zle reset-prompt | |
return $ret | |
} | |
zle -N fzy-file-widget | |
bindkey '^T' fzy-file-widget | |
# CTRL-R - Paste the selected command from history into the command line | |
fzy-history-widget() { | |
local selected num | |
setopt localoptions noglobsubst noposixbuiltins pipefail 2> /dev/null | |
selected=$(fc -rl 1 | fzy) | |
local ret=$? | |
if [ -n "$selected" ]; then | |
num=$selected[1] | |
if [ -n "$num" ]; then | |
zle vi-fetch-history -n $num | |
fi | |
fi | |
zle reset-prompt | |
return $ret | |
} | |
zle -N fzy-history-widget | |
bindkey '^X^R' fzy-history-widget |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment