Skip to content

alias with windows path which contains a space #3363

Closed

Description

@jbolda

Describe the bug
I am attempting to rewrite my (git-)bash alias into the startup config. The alias in bash was alias notes='code ~/Google\ Drive/Notes'. I have encountered a myriad of different failure cases, and haven't been able to get it working.

To Reproduce
Steps to reproduce the behavior:


  1. "alias notes = code ~/Google\ Drive/notes",
    image

  1. "alias notes = code \"~/Google Drive/notes\"", doesn't escape the space and doesn't open the correct folder

  1. "alias notes = code \"~/Google\ Drive/notes\"",
    image

  1. "alias notes = code '~/Google Drive/notes'", doesn't escape the space

  1. 'alias notes = code "~/Google Drive/notes"', doesn't escape the space

  1. 'alias notes = code "~/Google Drive/notes/boop.txt"', doesn't escape the space (and screenshot below for what actually opens)
    note: ~ is C:\Users\Jacob
    image

Expected behavior
The expectation is that it opens vscode (code) at the specified folder (which happens to have a space).

Screenshots
See reproduction.

Configuration (please complete the following information):

Note, the below seems a tad misleading, as it was installed via scoop.

────┬────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────
 #  │      Column0       │                                                 Column1
────┼────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────
  0 │ version            │ 0.30.0
  1 │ short_commit       │ 02d57299
  2 │ commit_hash        │ 02d5729941c9e5ad013889e1b9c452cc40a8e4df
  3 │ commit_date        │ 2021-04-21 02:31:54
  4 │ build_os           │ windows-x86_64
  5 │ rust_version       │ rustc 1.51.0 (2fd73fabe 2021-03-23)
  6 │ rust_channel       │ stable-x86_64-pc-windows-msvc (default)
  7 │ cargo_version      │ cargo 1.51.0 (43b129a20 2021-03-16)
  8 │ pkg_version        │ 0.30.0
  9 │ build_time         │ 2021-04-21 05:40:50
 10 │ build_rust_channel │ release
 11 │ features           │ clipboard-cli, ctrlc, default, directories, dirs, ichwh, ptree, rustyline, term, trash, uuid, which, zip
────┴────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────

Activity

  1. fdncred commented on Apr 27, 2021

    @fdncred
    Contributor

    What happens when you don't use the tilde and you full path it? I've seen ~ not work right on all platforms.

  2. jbolda commented on Apr 27, 2021

    @jbolda
    Author

    It appears to be the exact same behavior. Note that code ~ does work and opens the expected folder. Both directly in the shell and as an alias.

  3. fdncred commented on Apr 29, 2021

    @fdncred
    Contributor

    @jbolda I put this in my config.toml startup = [ section and it worked. It's not exactly what you're doing but similar.

        "alias notes1 = code.cmd \"C:\\Program Files\\WinRAR\\Rar.txt\"",
        "alias notes2 = code.cmd 'C:\\Program Files\\WinRAR\\Rar.txt'",
    

    Can you try something similar to see if you have success? For me, the key was calling code.cmd instead of just code

  4. fdncred commented on Apr 29, 2021

    @fdncred
    Contributor

    I also added #3367 which seems to make code and code.cmd work now but i can't tell you why. lol

  5. jbolda commented on May 7, 2021

    @jbolda
    Author

    Thanks!

    It looks like even "alias notes = code 'C:\\Users\\Jacob\\Google Drive\\notes'", works for me. So I don't know that the .cmd is specifically required? It seems like the typical path issues that arise on windows. It doesn't seem that ~ works at all though here.

  6. github-actions commented on Jun 24, 2021

    @github-actions

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

  7. aminya commented on Sep 17, 2021

    @aminya
    Contributor

    Is it possible to spawn paths that have spaces in them?

    Currently, I can only shell out to cmd:

    cmd /c "C:/Program Files/SomeProgram/something.exe" --help
    
  8. fdncred commented on Sep 17, 2021

    @fdncred
    Contributor

    @aminya how are you using this? within a nu script or from the prompt? I was able to do this from the prompt and get the help dialog to appear.

    ^cmd /c "C:/Program Files/TortoiseGit/bin/TortoiseGitProc.exe" --help
    
  9. aminya commented on Sep 17, 2021

    @aminya
    Contributor

    Yeah, my question is for not using cmd. Spawning directly from nu.

  10. fdncred commented on Sep 17, 2021

    @fdncred
    Contributor

    @aminya how about something like this ^'C:/Program Files/TortoiseGit/bin/TortoiseGitProc.exe' '--help' this also works for me with the slashes in the other direction ^'C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe' '--help'

  11. aminya commented on Sep 17, 2021

    @aminya
    Contributor

    Oh, nice. I didn't know that ^ is able to spawn commands! This should be documented on the first page of Nushell. This is essential for Windows users. 😄

  12. fdncred commented on Sep 17, 2021

    @fdncred
    Contributor
  13. pwnorbitals commented on Mar 20, 2022

    @pwnorbitals

    @jbolda It looks like your issue has been resolved, can this issue be closed ?

  14. hustcer commented on May 10, 2022

    @hustcer
    Contributor

    Please try nu after v0.62, and feel free to reopen if you still have such issues

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions