-
Notifications
You must be signed in to change notification settings - Fork 215
Document session restore interaction with command-line arguments #913
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
Draft
Copilot
wants to merge
5
commits into
main
Choose a base branch
from
copilot/update-command-line-arguments-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
10c15a7
Initial plan
Copilot 397b755
Add documentation for session restore behavior with command line argu…
Copilot e1ee1d2
Fix comment syntax in PowerShell and Bash examples
Copilot fb863f0
Fix comment syntax for Command Prompt to use REM
Copilot 84e538c
Revert to consistent comment syntax matching existing documentation s…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,14 @@ wt [options] [command ; ] | |
| > [!NOTE] | ||
| > The [`windowingBehavior` property](./customize-settings/startup.md#new-instance-behavior) can affect the behavior of the `wt.exe` command. Adjust this setting to default between opening a new window or opening a new tab. | ||
|
|
||
| > [!IMPORTANT] | ||
| > If you have enabled the **"Open windows from a previous session"** startup option ([`firstWindowPreference: "persistedWindowLayout"`](./customize-settings/startup.md#behavior-when-starting-a-new-terminal-session)), running `wt` from the command line will restore your previous session **and** execute the command you provided, potentially opening two windows. To prevent this behavior, use the `--window, -w` option to control where your command executes: | ||
| > - `wt -w 0 nt -p <profile>` - Opens in the most recently used window (prevents a second window from opening) | ||
| > - `wt -w -1 nt -p <profile>` - Forces a new window without restoring the previous session | ||
| > - `wt -w <name> nt -p <profile>` - Opens in a named window, creating it only if it doesn't exist | ||
| > | ||
| > See the [`--window` option](#options-and-commands) below for more details. | ||
|
|
||
| To display a help message that lists the available command line arguments, enter: `wt -h`, `wt --help`, `wt -?`, or `wt /?`. | ||
|
|
||
| ## Options and commands | ||
|
|
@@ -214,6 +222,57 @@ Execution aliases don't work in WSL distributions. If you want to use wt.exe fro | |
| --- | ||
| <!-- End tab selectors. --> | ||
|
|
||
| ### Session restore and command line arguments | ||
|
|
||
| If you have enabled the **"Open windows from a previous session"** startup option ([`firstWindowPreference: "persistedWindowLayout"`](./customize-settings/startup.md#behavior-when-starting-a-new-terminal-session)), running `wt` with command line arguments will both restore your previous session layout **and** execute your command, which may result in opening two windows. | ||
|
|
||
| To avoid this behavior when session restore is enabled, use the `--window, -w` option to control where your commands execute: | ||
|
|
||
| <!-- Start tab selectors. --> | ||
| #### [Command Prompt](#tab/windows) | ||
|
|
||
| ```cmd | ||
| // Open a new tab with a specific profile in the most recently used window (avoids opening a second window) | ||
| wt -w 0 nt -p "Ubuntu-18.04" | ||
|
|
||
| // Force a new window with the profile, without restoring previous session | ||
| wt -w -1 nt -p "Command Prompt" | ||
|
|
||
| // Open in a named window (creates it only if it doesn't exist) | ||
| wt -w mywork nt -p "PowerShell" | ||
| ``` | ||
|
|
||
| #### [PowerShell](#tab/powershell) | ||
|
|
||
| ```powershell | ||
| // Open a new tab with a specific profile in the most recently used window (avoids opening a second window) | ||
| wt -w 0 nt -p "Ubuntu-18.04" | ||
|
|
||
| // Force a new window with the profile, without restoring previous session | ||
| wt -w -1 nt -p "Command Prompt" | ||
|
|
||
| // Open in a named window (creates it only if it doesn't exist) | ||
| wt -w mywork nt -p "PowerShell" | ||
| ``` | ||
|
|
||
| #### [Linux](#tab/linux) | ||
|
|
||
| ```bash | ||
| // Open a new tab with a specific profile in the most recently used window (avoids opening a second window) | ||
| cmd.exe /c "wt.exe" -w 0 nt -p "Ubuntu-18.04" | ||
|
|
||
| // Force a new window with the profile, without restoring previous session | ||
| cmd.exe /c "wt.exe" -w -1 nt -p "Command Prompt" | ||
|
|
||
| // Open in a named window (creates it only if it doesn't exist) | ||
| cmd.exe /c "wt.exe" -w mywork nt -p "PowerShell" | ||
| ``` | ||
|
|
||
| Execution aliases don't work in WSL distributions. If you want to use wt.exe from a WSL command line, you can spawn it from CMD directly by running `cmd.exe`. The `/c` option tells CMD to terminate after running. | ||
|
|
||
| --- | ||
| <!-- End tab selectors. --> | ||
|
Comment on lines
+229
to
+274
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similarly, drop this all. |
||
|
|
||
| ### Open a new profile instance | ||
|
|
||
| To open a new terminal instance, such as the profile named "Ubuntu-18.04", enter: | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(starting from "To prevent this behavior, use the
--window, -woption to control where your command executes:")Nope. This doesn't work this way. Don't add any commentary on how to prevent that behavior - when
firstWindowPreferenceis set to restore things, then any coldwt ntcommand will both restore and run the new command.