Skip to content

Instantly share code, notes, and snippets.

@ysmood
Created January 9, 2019 11:40
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 ysmood/fed2a82384bbc269fb9a760ef9f877bf to your computer and use it in GitHub Desktop.
Save ysmood/fed2a82384bbc269fb9a760ef9f877bf to your computer and use it in GitHub Desktop.
fzf config for zsh
####### 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