From 10c15a74a762f7a2446e8b46c37f9a8f8b0228e0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Dec 2025 20:10:26 +0000 Subject: [PATCH 1/5] Initial plan From 397b75516c35eff1c0d8085cc3bd1b7c0ba289d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Dec 2025 20:23:37 +0000 Subject: [PATCH 2/5] Add documentation for session restore behavior with command line arguments Co-authored-by: mattwojo <7566797+mattwojo@users.noreply.github.com> --- TerminalDocs/command-line-arguments.md | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/TerminalDocs/command-line-arguments.md b/TerminalDocs/command-line-arguments.md index 67372893..bfb2513d 100644 --- a/TerminalDocs/command-line-arguments.md +++ b/TerminalDocs/command-line-arguments.md @@ -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 ` - Opens in the most recently used window (prevents a second window from opening) +> - `wt -w -1 nt -p ` - Forces a new window without restoring the previous session +> - `wt -w nt -p ` - 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 --- +### 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: + + +#### [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. + +--- + + ### Open a new profile instance To open a new terminal instance, such as the profile named "Ubuntu-18.04", enter: From e1ee1d26d882c177189ffddabbb5682abf4e8a7d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Dec 2025 20:27:08 +0000 Subject: [PATCH 3/5] Fix comment syntax in PowerShell and Bash examples Co-authored-by: mattwojo <7566797+mattwojo@users.noreply.github.com> --- TerminalDocs/command-line-arguments.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/TerminalDocs/command-line-arguments.md b/TerminalDocs/command-line-arguments.md index bfb2513d..226b6dd0 100644 --- a/TerminalDocs/command-line-arguments.md +++ b/TerminalDocs/command-line-arguments.md @@ -245,26 +245,26 @@ 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) +# 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 +# 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) +# 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) +# 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 +# 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) +# Open in a named window (creates it only if it doesn't exist) cmd.exe /c "wt.exe" -w mywork nt -p "PowerShell" ``` From fb863f0e7091ced2048f16aab88f81f4fb372233 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Dec 2025 20:28:31 +0000 Subject: [PATCH 4/5] Fix comment syntax for Command Prompt to use REM Co-authored-by: mattwojo <7566797+mattwojo@users.noreply.github.com> --- TerminalDocs/command-line-arguments.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TerminalDocs/command-line-arguments.md b/TerminalDocs/command-line-arguments.md index 226b6dd0..72bcd164 100644 --- a/TerminalDocs/command-line-arguments.md +++ b/TerminalDocs/command-line-arguments.md @@ -232,13 +232,13 @@ To avoid this behavior when session restore is enabled, use the `--window, -w` o #### [Command Prompt](#tab/windows) ```cmd -// Open a new tab with a specific profile in the most recently used window (avoids opening a second window) +REM 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 +REM 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) +REM Open in a named window (creates it only if it doesn't exist) wt -w mywork nt -p "PowerShell" ``` From 84e538c647332e346c4aa8b39bc00acdbb74a6ed Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Dec 2025 20:30:23 +0000 Subject: [PATCH 5/5] Revert to consistent comment syntax matching existing documentation style Co-authored-by: mattwojo <7566797+mattwojo@users.noreply.github.com> --- TerminalDocs/command-line-arguments.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/TerminalDocs/command-line-arguments.md b/TerminalDocs/command-line-arguments.md index 72bcd164..bfb2513d 100644 --- a/TerminalDocs/command-line-arguments.md +++ b/TerminalDocs/command-line-arguments.md @@ -232,39 +232,39 @@ To avoid this behavior when session restore is enabled, use the `--window, -w` o #### [Command Prompt](#tab/windows) ```cmd -REM Open a new tab with a specific profile in the most recently used window (avoids opening a second window) +// 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" -REM Force a new window with the profile, without restoring previous session +// Force a new window with the profile, without restoring previous session wt -w -1 nt -p "Command Prompt" -REM Open in a named window (creates it only if it doesn't exist) +// 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) +// 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 +// 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) +// 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) +// 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 +// 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) +// Open in a named window (creates it only if it doesn't exist) cmd.exe /c "wt.exe" -w mywork nt -p "PowerShell" ```