Skip to content

Commit d4c999d

Browse files
committed
[fish] Fix for file/dir names containing newlines
CTRL-T/ALT-C now works correctly when selecting files or directories that contain newlines in their names. When external commands defined by $FZF_CTRL_T_COMMAND/$FZF_ALT_C_COMMAND are used (for example the fd command with -0 switch), the --read0 option must also be set through $FZF_CTRL_T_OPTS/$FZF_ALT_C_OPTS.
1 parent e15cba0 commit d4c999d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

shell/key-bindings.fish

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ function fzf_key_bindings
9696

9797
set -lx FZF_DEFAULT_OPTS (__fzf_defaults \
9898
"--reverse --walker=file,dir,follow,hidden --scheme=path --walker-root=$dir" \
99-
"$FZF_CTRL_T_OPTS --multi")
99+
"$FZF_CTRL_T_OPTS --multi --print0")
100100

101101
set -lx FZF_DEFAULT_COMMAND "$FZF_CTRL_T_COMMAND"
102102
set -lx FZF_DEFAULT_OPTS_FILE
103103

104-
if set -l result (eval (__fzfcmd) --query=$fzf_query)
104+
if set -l result (eval (__fzfcmd) --query=$fzf_query | string split0)
105105
# Remove last token from commandline.
106106
commandline -t ''
107107
for i in $result
@@ -155,12 +155,12 @@ function fzf_key_bindings
155155

156156
set -lx FZF_DEFAULT_OPTS (__fzf_defaults \
157157
"--reverse --walker=dir,follow,hidden --scheme=path --walker-root=$dir" \
158-
"$FZF_ALT_C_OPTS --no-multi")
158+
"$FZF_ALT_C_OPTS --no-multi --print0")
159159

160160
set -lx FZF_DEFAULT_OPTS_FILE
161161
set -lx FZF_DEFAULT_COMMAND "$FZF_ALT_C_COMMAND"
162162

163-
if set -l result (eval (__fzfcmd) --query=$fzf_query)
163+
if set -l result (eval (__fzfcmd) --query=$fzf_query | string split0)
164164
cd -- $result
165165
commandline -rt -- $prefix
166166
end

0 commit comments

Comments
 (0)