Created
January 9, 2019 11:40
-
-
Save ysmood/fed2a82384bbc269fb9a760ef9f877bf to your computer and use it in GitHub Desktop.
fzf config for zsh
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
####### fzf ###### | |
if type "fzf" > /dev/null; then | |
FZF_DEFAULT_OPTS='--layout=reverse --border' | |
# CTRL-R - Paste the selected command from history into the command line | |
fzf-history-widget() { | |
local selected num | |
setopt localoptions noglobsubst noposixbuiltins pipefail 2> /dev/null | |
selected=( $(fc -rln 1 | | |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" fzf) ) | |
local ret=$? | |
if [ -n "$selected" ]; then | |
LBUFFER=$selected | |
fi | |
zle reset-prompt | |
return $ret | |
} | |
zle -N fzf-history-widget | |
bindkey '^R' fzf-history-widget | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment