Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Support tilde (~) shortcut to user profile in -d argument #7454

Closed
Ariane-B opened this issue Aug 28, 2020 · 10 comments
Closed

CLI: Support tilde (~) shortcut to user profile in -d argument #7454

Ariane-B opened this issue Aug 28, 2020 · 10 comments
Labels
Area-Commandline wt.exe's commandline arguments good first issue This is a fix that might be easier for someone to do as a first contribution Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-Fix-Available It's available in an Insiders build or a release
Milestone

Comments

@Ariane-B
Copy link

Description of the new feature/enhancement

Currently, if I want to open a Terminal tab that starts in a specific folder in my user profile, I have to write -d C:\Users\MyUser\somefolder. I wish I could use the shortcut ~ to say "that's my user folder".

Proposed technical implementation details (optional)

For example, I could use the command wt -d ~/somefolder, which would be equivalent to wt -d C:\Users\MyUser\somefolder.

@Ariane-B Ariane-B added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Aug 28, 2020
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Aug 28, 2020
@DHowett
Copy link
Member

DHowett commented Sep 4, 2020

Hey, this is a good idea.

@DHowett DHowett added Area-Commandline wt.exe's commandline arguments good first issue This is a fix that might be easier for someone to do as a first contribution Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Sep 4, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Sep 4, 2020
@DHowett DHowett added this to the Terminal Backlog milestone Sep 4, 2020
@kaifee-haque
Copy link

Looks like we can already open a Terminal tab that starts in C:\Users\MyUser\somefolder by using the command wt -d somefolder.

@Ariane-B
Copy link
Author

Ariane-B commented Sep 5, 2020

That is cool, but it would be nice if it were clearer in the docs, because I was convinced the root for the -d parameter was "My PC" or "C:".

@DHowett
Copy link
Member

DHowett commented Sep 5, 2020

As with all Windows applications, the root of any relative directory parameter is the current working directory.

This means that if you run wt -d x from C:\a it will start a profile in C:\a\x.

We opted not to document behavior that is either incidental or not a deviation from other applications :)

@Ariane-B
Copy link
Author

Ariane-B commented Sep 5, 2020

Oh, that's what you meant! I thought you meant that the -d argument was always based on the current user's directory. If the base is the current command line directory, then my suggestion stands.

What you describe makes perfect sense. But in the context of a startup shortcut, for example, the directory it runs from is not immediately obvious. Add in general, I don't think it's entirely safe to assume everyone will always be running the shell command line from their home folder.

Also, there might be cases where a single shell file will be run by several users, who'd want the starting directory to be in -their- user folder.

Finally, some people like to specify things when they're insecure about what the automatic behaviour would be. Simply mentioning the thing is sometimes simpler than researching the default behaviour, after all.

For all these reasons, I think I'll stand behind my suggestion.

@KnapSac
Copy link
Contributor

KnapSac commented Sep 9, 2020

Can I pick this up?

@zadjii-msft
Copy link
Member

I'm a little worried about this request. Treating ~ as %USERPROFILE%seems like a good idea, but what if someone wants to use ~ as their WSL ~ directory, not their Windows one?

IMO I'd want that question answered before we ship this.

@KnapSac
Copy link
Contributor

KnapSac commented Sep 9, 2020

Maybe that should depend on the profile you're targeting? For instance, when opening a WSL profile we could treat ~ as their WSL ~ directory, and for other profiles we could treat it as %USERPROFILE%.

@zadjii-msft
Copy link
Member

Ah but how do we know for certain if they"re targeting a WSL profile? The user could make other WSL profiles other than the dynamically generated ones. In that case, we wouldn't have the source data to tell use that the profile is a WSL profile. Maybe we need to add another wslDistro property that identifies which distro the profile is for. That might play into #592 (et al) as well.

/cc @DHowett since we've been having discussion about this in the past

@zadjii-msft zadjii-msft modified the milestones: Terminal Backlog, Backlog Jan 4, 2022
@zadjii-msft
Copy link
Member

We might have low key done this unintentionally.

#12437

If we find that we were unable to mangle ~ into the user's WSL commandline, then we will re-evaluate that startingDirectory as %USERPROFILE%, which is at least something sensible, if albeit not what they wanted.

I mean, it makes sense. ~ isn't a valid path for a Windows process, but it is for a WSL process. We've already got some magic to make this work for WSL processes. Now we've got different magic to make it work for anything other than wsl.exe. If we see a startingDirectory of ~, we're gonna treat it like %USERPROFILE% now.

This should be in Terminal v1.12.10393.0, Terminal Preview v1.13.10395.0

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Mar 3, 2022
@zadjii-msft zadjii-msft added the Resolution-Fix-Available It's available in an Insiders build or a release label Mar 3, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Commandline wt.exe's commandline arguments good first issue This is a fix that might be easier for someone to do as a first contribution Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-Fix-Available It's available in an Insiders build or a release
Projects
None yet
Development

No branches or pull requests

6 participants
@DHowett @Ariane-B @zadjii-msft @KnapSac @kaifee-haque and others