dotfiles/zsh/funcs/skim.funcs
2020-01-01 14:08:41 -05:00

19 lines
758 B
Text

# This entire thing almost entirely, shamelessly stolen from fzf/shell/key-bindings.zsh, replacing fzf with skim
export SKIM_DEFAULT_COMMAND="rg --files"
skim-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
selected=( $(fc -rl 1 |
SKIM_DEFAULT_OPTS="--height ${SKIM_TMUX_HEIGHT:-40%} $SKIM_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $SKIM_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" sk-tmux -d${SKIM_TMUX_HEIGHT} ))
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 skim-history-widget
bindkey '^R' skim-history-widget