Skip to content

Support escape space by backslash in command line #12464

Description

@PRNDA

Related problem

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!

Like this: diff /Users/mac/Downloads/a\ hourly\ list\ 1.txt /Users/mac/another \dir/and\ another\ file.txt

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.

Image

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

Describe alternatives you've considered

No response

Additional context and details

No response

Activity

  1. added
    category:enhancement
    status:needs-triage
    on Apr 10, 2024
  2. devyn commented on Apr 12, 2024

    @devyn
    Contributor

    While your use case makes sense, I wonder if it might conflict with our support for Windows paths.

  3. kaathewisegit commented on Apr 14, 2024

    @kaathewisegit
    Contributor

    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.

  4. PRNDA commented on Apr 15, 2024

    @PRNDA
    Author

    While your use case makes sense, I wonder if it might conflict with our support for Windows paths.

    Maybe we could use a switch to control this behavior in difference OS.

  5. sholderbach commented on Apr 15, 2024

    @sholderbach
    Member

    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.

  6. added
    A:quoting-expansion
    on Apr 15, 2024
  7. removed
    status:needs-triage
    on Jul 13, 2024
  8. bratorange commented on Jan 26, 2025

    @bratorange

    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?

  9. oderwat commented on Feb 25, 2025

    @oderwat

    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.

  10. PRNDA commented on Feb 25, 2025

    @PRNDA
    Author

    also escaped parenthesis and other characters I suppose

    Yes, all special characters are automatically escaped.

    A MUST-HAVE feature.

  11. kaathewisegit commented on Feb 25, 2025

    @kaathewisegit
    Contributor

    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

  12. jobukkit commented on May 17, 2025

    @jobukkit

    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.

  13. 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
  14. 8 remaining items

  15. ronisbr commented on May 27, 2026

    @ronisbr
    Contributor

    I am not sure about OP, but my use case would be solved if the escape for spaces works inside double-quotes only.

  16. oderwat commented on May 27, 2026

    @oderwat

    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.

    Example for a drag&drop file path in Ghostty:

    Image
  17. fdncred commented on May 27, 2026

    @fdncred
    Contributor

    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.

  18. jobukkit commented on May 27, 2026

    @jobukkit

    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.

  19. oderwat commented on May 27, 2026

    @oderwat

    ... "dragging files" ...

    Being able to type a ", drag and drop, then type another " would arguably be enough already.

    This would work for a single file being dragged. But you can drag multiple ones. Which makes it even more useful.

  20. fdncred commented on May 27, 2026

    @fdncred
    Contributor

    How would this work in Windows?

  21. PRNDA commented on May 28, 2026

    @PRNDA
    Author

    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:

    ls "spaces in file names.txt"

  22. oderwat commented on May 28, 2026

    @oderwat

    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.

  23. ronisbr commented on Jun 16, 2026

    @ronisbr
    Contributor

    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.

  24. ronisbr commented on Sep 10, 2026

    @ronisbr
    Contributor

    Hi!

    Any conclusions about this issue? I can make a PR if devs decide what direction we should take.

  25. fdncred commented on Sep 10, 2026

    @fdncred
    Contributor

    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.

  26. ronisbr commented on Sep 10, 2026

    @ronisbr
    Contributor

    @fdncred Done! The idea is that now we can type " drag-and-drop and ". It is not breaking because it was an error before.

  27. added a commit that references this issue on Sep 10, 2026
    1ed063b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:quoting-expansioncategory:enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions