diff options
author | Florian Pritz <bluewind@xinu.at> | 2019-06-25 10:05:15 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2019-07-06 14:19:22 +0200 |
commit | ad746c2032c713fd6c57bcc8e601ab43704e1fa9 (patch) | |
tree | 5f12ac80d557494b2d3fa0090844e8c2b54779cd /.zshrc | |
parent | 1bb34277ea19e7d3af39ec41f51b2553bd407f75 (diff) | |
download | dotfiles-ad746c2032c713fd6c57bcc8e601ab43704e1fa9.tar.gz dotfiles-ad746c2032c713fd6c57bcc8e601ab43704e1fa9.tar.xz |
zshrc: Add fzf file selection
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to '.zshrc')
-rw-r--r-- | .zshrc | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -209,6 +209,8 @@ globalias() { zle -N globalias bindkey ",," globalias +FZF_TMUX_HEIGHT='95%' + # Source: https://github.com/junegunn/fzf/blob/master/shell/key-bindings.zsh __fzf_use_tmux__() { [ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-0}" != 0 ] && [ ${LINES:-40} -gt 15 ] @@ -239,6 +241,30 @@ zle -N fzf-history-widget bindkey '^R' fzf-history-widget +__fsel() { + local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ + -o -type f -print \ + -o -type d -print \ + -o -type l -print 2> /dev/null | cut -b3-"}" + setopt localoptions pipefail 2> /dev/null + eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do + echo -n "${(q)item} " + done + local ret=$? + echo + return $ret +} + +fzf-file-widget() { + LBUFFER="${LBUFFER}$(__fsel)" + local ret=$? + zle reset-prompt + return $ret +} + +zle -N fzf-file-widget +bindkey '^T' fzf-file-widget + # }}} # Variables {{{ #export CDPATH=.:$HOME |