Skip to content

Commit

Permalink
zsh keybindings: ctrl-t: pass the last buffer word as query
Browse files Browse the repository at this point in the history
  • Loading branch information
bretello committed Dec 21, 2023
1 parent 87fc1c8 commit 94fab6f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions shell/key-bindings.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ fi

{

# CTRL-T - Paste the selected file path(s) into the command line
# CTRL-T - Paste the selected file path(s) into the command line using the last part of the buffer as fzf query
__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 no_aliases 2> /dev/null
local item
eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --scheme=path --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_CTRL_T_OPTS-}" $(__fzfcmd) -m "$@" | while read item; do
local -a words=(${(z)LBUFFER})
local query=${words[-1]}
eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --scheme=path --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_CTRL_T_OPTS-}" $(__fzfcmd) -m --query=${query} | while read item; do
echo -n "${(q)item} "
done
local ret=$?
Expand Down

0 comments on commit 94fab6f

Please sign in to comment.