-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Other options for overriding profile starting directory #4637
Comments
For I'm concerned about the veritable pandora's box of features that opens up as well: if we can override This likely warrants further discussion. 😄 |
I hadn't seen #3158 when I was looking around, that appears to cover I think you're right adding The For defaults, just launching from the standard shortcut in start menu / task bar uses Maybe a better approach that still covers what I'm hoping for would be an optional |
In Ubuntu, when I press ctrl+alt+T, the terminal will launch at |
@waahoo you might be interested in #878. Specifically, this: #878 (comment), and the PR #3547, and the investigation that was done in that PR. |
Copying my post from #9991, which was basically the same thing
|
From @UmbralReaper in #12200
|
Some notes: a work in progress 🏗️ Scenarios
Scenario A & B"Use parent process directory" still works after the 1.18 process model changes
This is in 816f8b2
This will break a profile like {
"commandline": "media-test.exe",
"hidden": false,
"name": "Use CWD for media-test",
"startingDirectory": "."
}, if the user right-clicks "open in terminal", then attempts to open that profile. UNLESS we do some work down in D/E Scenario CCtrl+clicking on a "Use parent process directory" profile starts it in the original terminal's CWD.
A 1.18 version of this, which builds on A&B, is in 3d1611f Scenario D & EThe user can set & change the CWD of the terminal itself A couple new features:
Potential fix for the C breakWe change the shell extension to call Scenario FAn auto-elevate default profile, with a "Use parent process directory" profile, should inherit the CWD that the terminal was ORIGINALLY started with (before it was auto-elevated)
Planning
A & B can be done for 1.18, with mild risk. ReferencesLemme just cross link a bunch of threads. I used to have a better mental map for this problem space.
|
Before process model v3, each Terminal window was running in its own process, each with its own CWD. This allowed `startingDirectory: .` to work relative to the terminal's own CWD. However, now all windows share the same process, so there can only be one CWD. That's not great - folks who right-click "open in terminal", then "Use parent process directory" are only ever going to be able to use the CWD of the _first_ terminal opened. This PR remedies this issue, with a theory we had for another issue. Essentially, we'll give each Terminal window a "virtual" CWD. The Terminal isn't actually in that CWD, the terminal is in `system32`. This also will prevent the Terminal from locking the directory it was originally opened in. * Closes #5506 * There wasn't a 1.18 issue for "Use parent process directory is broken" yet, presumably selfhosters aren't using that feature * Related to #14957 Many more notes on this topic in #4637 (comment) > **Warning** > ## Breaking change‼️ This will break a profile like ```json { "commandline": "media-test.exe", "name": "Use CWD for media-test", "startingDirectory": "." }, ``` if the user right-clicks "open in terminal", then attempts to open that profile. There's some theoretical work we could do in a follow up to fix this, but I'm inclined to say that relative paths for `commandline`s were already dangerous and should have been avoided.
Before process model v3, each Terminal window was running in its own process, each with its own CWD. This allowed `startingDirectory: .` to work relative to the terminal's own CWD. However, now all windows share the same process, so there can only be one CWD. That's not great - folks who right-click "open in terminal", then "Use parent process directory" are only ever going to be able to use the CWD of the _first_ terminal opened. This PR remedies this issue, with a theory we had for another issue. Essentially, we'll give each Terminal window a "virtual" CWD. The Terminal isn't actually in that CWD, the terminal is in `system32`. This also will prevent the Terminal from locking the directory it was originally opened in. * Closes #5506 * There wasn't a 1.18 issue for "Use parent process directory is broken" yet, presumably selfhosters aren't using that feature * Related to #14957 Many more notes on this topic in #4637 (comment) > **Warning** > ## Breaking change‼️ This will break a profile like ```json { "commandline": "media-test.exe", "name": "Use CWD for media-test", "startingDirectory": "." }, ``` if the user right-clicks "open in terminal", then attempts to open that profile. There's some theoretical work we could do in a follow up to fix this, but I'm inclined to say that relative paths for `commandline`s were already dangerous and should have been avoided. (cherry picked from commit 5c08a86) Service-Card-Id: 89180224 Service-Version: 1.18
Adds an action to display a toast containing the Terminal's "virtual" CWD. As described in #4637 (comment). Useful for debugging #5506 et. al. I almost left it as a debug-only feature, but figured it would be helpful for others in the #4637 landscape of things.
I would call the current situation the “default directory madness”:
So in summary: I doubled every profile and I also created a script to actually open the terminal. The following behaviour would cover my use case:
|
Interesting issue with the start in parent process directory option - if you subsequently delete that directory, you cannot start another tab without an error (this example is with Command Prompt as the default): [error 2147942667 (0x8007010b) when launching `%SystemRoot%\System32\cmd.exe'] On Windows 11 23H2 (OS Build 22631.3880) with Windows Terminal 1.20.11781.0 |
Description of the new feature/enhancement
The new command line arg for specifying starting directory is great but it's limited to individual panes and tabs created during launch. I'd like additional ways of specifying starting directories for panes/tabs, particularly those that get created after launch. Here's two additions I think would be useful:
Window-wide starting directory command line argument
Starting a terminal with
wt --windowStartingDirectory "c:\my\project\dir"
would cause all tabs/panes opened during the life of that terminal window to start inc:\my\project\dir
. This is useful for opening a terminal window directly in a deeply nested project directory and then quickly and easily opening/closing additional panes/tabs in that location. This should also apply to all panes/tabs created via initial command line args that don't have an individual--startingDirectory
specified.You can more or less achieve this right now by setting a profile's starting directory to
.
and startingwt.exe
itself with the actual desired starting directory as working directory. However this requires a more complicated launch, eg.cmd /C start /D "c:\my\project\dir" wt
. You also lose the ability to keep a useful default starting directory in the profile's settings for a simple launch ofwt.exe
.newTab and splitPane keybind options for reusing current directory
An additional option for the newTab/splitPane keybindings could open these with starting directory set to the current working directory of the current tab/pane. Useful if you open a terminal, eventually
cd
to some directory, and then want additional panes/tabs in that directory.These would be additions to a prioritized list where the tab/pane being created uses the highest priority starting directory that was provided, eg:
--startingDirectory
command line argument--windowStartingDirectory
command line argumentwt.exe
working directoryThe text was updated successfully, but these errors were encountered: