Skip to content

Commit 94fab6f

Browse files
committed
zsh keybindings: ctrl-t: pass the last buffer word as query
1 parent 87fc1c8 commit 94fab6f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: shell/key-bindings.zsh

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ fi
3939

4040
{
4141

42-
# CTRL-T - Paste the selected file path(s) into the command line
42+
# CTRL-T - Paste the selected file path(s) into the command line using the last part of the buffer as fzf query
4343
__fsel() {
4444
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 \
4545
-o -type f -print \
4646
-o -type d -print \
4747
-o -type l -print 2> /dev/null | cut -b3-"}"
4848
setopt localoptions pipefail no_aliases 2> /dev/null
4949
local item
50-
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
50+
local -a words=(${(z)LBUFFER})
51+
local query=${words[-1]}
52+
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
5153
echo -n "${(q)item} "
5254
done
5355
local ret=$?

0 commit comments

Comments
 (0)