You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support escape space by backslash in command line #12464
I use Mac as my primary system, and Mac's Terminal.app is perfectly integrated with the whole system, for example, if I drag (or copy-and-paste) files/folders into a Terminal window, it will paste the full file path into the command line, and the space characters in the file path is escaped by a backslash automatically!
This is a very convenient feature for a man who uses the command line heavily, especially when you need to copy-and-paste a lot of file paths.
But nushell does not support escape space by backslash( <space>), this makes my daily work a bit harder, because I use copy-and-paste files/folders into the Terminal now and then all the day.
Describe the solution you'd like
I would like nushell to support escape space by backslash like this: /Users/mac/Downloads/a\ hourly\ list.txt
This would also require changing the semantics of unquoted strings, which do not support escapes. So, unlike in other shells, print \t will output \t literally.
We are commited that Nushell does not display platform differences for the core language, so configuration options, switches, or platform detection are out of the question for syntax level questions.
We are commited that Nushell does not display platform differences for the core language, so configuration options, switches, or platform detection are out of the question for syntax level questions.
But would a config option to change this behavior compatible with the design concept / community?
Reacted by PRNDA(A for Auto), jobukkit and Míla Kuchta
I would also like to have this as an option. Especially becase dropping a file into a Ghostty terminal seems to always use the escapes. It is not just space that gets escaped there are also escaped parentesis and other characters I suppose. I understand the Window problem and also that one does not want to have different behavior. But then I wonder if this is really something that needs to be implemented on the "core" parser. Why not having it as an option for the terminal input only? I know this is very special, but if you are in the position that this is how it works, you get really tired of having to find ways to insert a path which is so easy to insert into (all?) other shells by just dropping it into the terminal pane. But I have to say that I was looking if one can change Ghostty before I ended up here.
Reacted by PRNDA(A for Auto), jobukkit and neurodynamic
If these terminals use bracketed paste mode, then it should be possible to catch these events and escape the whole path using Nushell-native quotes, much like the auto-completion does
changed the title [-]Support escape space by backslash( \<space>) in command line[/-][+]Support escape special chars by backslash( \<char>) in command line[/+]on May 19, 2025
It needs to work without double quotes to be useful when dragging files into a terminal on OSX. At least with original Terminal and with Ghostty. That said, AFAIK "\ " is a not a valid escape sequence in double quotes. But you may want to add a rule "f it is unknown, just ignore the \. I think that is done in some implementations.
The problem isn't really the escaping. That's easy to add. The problem is with everything that uses paths with spaces like completions, expanding ~, expanding ndots, command arguments, custom command arguments, highlighting, etc. It's kind of a can of worms.
It needs to work without double quotes to be useful when dragging files into a terminal on OSX.
Being able to type a ", drag and drop, then type another " would arguably be enough already. Some Linux terminals like Terminology make you do this for all shells.
It needs to work without double quotes to be useful when dragging files into a terminal on OSX.
Being able to type a ", drag and drop, then type another " would arguably be enough already. Some Linux terminals like Terminology make you do this for all shells.
If you just want this, than you don't need to do anything at all, because you can already do this:
I you just want this, than you don't need to do anything at all, because you can already do this:
ls "spaces in file names.txt"
I think what he means is that you can type the two " and insert the version that has "\ " in it. Result would be:
"spaces\ in\ file\ names.txt"
And the "\ " is supported as space escape for a string. Basically striping the \ in front of a space.
And it would indeed be "better" because right now one needs to go and remove those \ manually to not type everything again. But this is obviously a pain. I actually started to the "copy as path" in the bottom bar when I need a file path in the terminal. I would love to go back to just drag&drop.
Reacted by jobukkit, neurodynamic and Ronan Arraes Jardim Chagas
Indeed, allowing spaces to be escaped inside quotes will help a lot. In this case, we can add quotes and drag files and it will work. Right now, it is impossible.
Activity
devyn commentedon Apr 12, 2024
While your use case makes sense, I wonder if it might conflict with our support for Windows paths.
kaathewisegit commentedon Apr 14, 2024
This would also require changing the semantics of unquoted strings, which do not support escapes. So, unlike in other shells,
print \twill output\tliterally.PRNDA commentedon Apr 15, 2024
Maybe we could use a switch to control this behavior in difference OS.
sholderbach commentedon Apr 15, 2024
We are commited that Nushell does not display platform differences for the core language, so configuration options, switches, or platform detection are out of the question for syntax level questions.
bratorange commentedon Jan 26, 2025
But would a config option to change this behavior compatible with the design concept / community?
oderwat commentedon Feb 25, 2025
I would also like to have this as an option. Especially becase dropping a file into a Ghostty terminal seems to always use the escapes. It is not just space that gets escaped there are also escaped parentesis and other characters I suppose. I understand the Window problem and also that one does not want to have different behavior. But then I wonder if this is really something that needs to be implemented on the "core" parser. Why not having it as an option for the terminal input only? I know this is very special, but if you are in the position that this is how it works, you get really tired of having to find ways to insert a path which is so easy to insert into (all?) other shells by just dropping it into the terminal pane. But I have to say that I was looking if one can change Ghostty before I ended up here.
PRNDA commentedon Feb 25, 2025
Yes, all special characters are automatically escaped.
A MUST-HAVE feature.
kaathewisegit commentedon Feb 25, 2025
If these terminals use bracketed paste mode, then it should be possible to catch these events and escape the whole path using Nushell-native quotes, much like the auto-completion does
jobukkit commentedon May 17, 2025
This issue affects the Linux version of Ghostty too, so it's not MacOS-specific.
For iTerm2, you can fix it by enabling "Escape file names with quotes instead of backslashes" under the advanced settings.
This is the same issue as #11944.
[-]Support escape space by backslash( \<space>) in command line[/-][+]Support escape special chars by backslash( \<char>) in command line[/+]8 remaining items
ronisbr commentedon May 27, 2026
I am not sure about OP, but my use case would be solved if the escape for spaces works inside double-quotes only.
oderwat commentedon May 27, 2026
It needs to work without double quotes to be useful when dragging files into a terminal on OSX. At least with original
Terminaland withGhostty. That said, AFAIK "\ " is a not a valid escape sequence in double quotes. But you may want to add a rule "f it is unknown, just ignore the \. I think that is done in some implementations.Example for a drag&drop file path in Ghostty:
fdncred commentedon May 27, 2026
The problem isn't really the escaping. That's easy to add. The problem is with everything that uses paths with spaces like completions, expanding ~, expanding ndots, command arguments, custom command arguments, highlighting, etc. It's kind of a can of worms.
jobukkit commentedon May 27, 2026
Being able to type a ", drag and drop, then type another " would arguably be enough already. Some Linux terminals like Terminology make you do this for all shells.
oderwat commentedon May 27, 2026
This would work for a single file being dragged. But you can drag multiple ones. Which makes it even more useful.
fdncred commentedon May 27, 2026
How would this work in Windows?
PRNDA commentedon May 28, 2026
If you just want this, than you don't need to do anything at all, because you can already do this:
ls "spaces in file names.txt"oderwat commentedon May 28, 2026
I think what he means is that you can type the two " and insert the version that has "\ " in it. Result would be:
"spaces\ in\ file\ names.txt"
And the "\ " is supported as space escape for a string. Basically striping the \ in front of a space.
And it would indeed be "better" because right now one needs to go and remove those \ manually to not type everything again. But this is obviously a pain. I actually started to the "copy as path" in the bottom bar when I need a file path in the terminal. I would love to go back to just drag&drop.
ronisbr commentedon Jun 16, 2026
Indeed, allowing spaces to be escaped inside quotes will help a lot. In this case, we can add quotes and drag files and it will work. Right now, it is impossible.
ronisbr commentedon Sep 10, 2026
Hi!
Any conclusions about this issue? I can make a PR if devs decide what direction we should take.
fdncred commentedon Sep 10, 2026
have at it but it can't be a breaking change and it has to work on Windows, MacOS, and Linux like the rest of nushell.
ronisbr commentedon Sep 10, 2026
@fdncred Done! The idea is that now we can type
"drag-and-drop and". It is not breaking because it was an error before.Support escaped spaces inside double quotes (nushell#19010)