[PR #9300] Add support for naming windows with the -w parameter #27539

Closed
opened 2026-01-31 09:22:34 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/9300

State: closed
Merged: Yes


This finishes the implementation of --window to also accept a string
as the "name" of the window. So you can say

wt -w foo new-tab
wt -w foo split-pane

and have both those commands execute in the same window, the one named
"foo". This is just slightly more ergonomic than manually using the IDs
of windows. In the future, I'll be working on renaming windows, and
displaying these names.

--window,-w <window-id>

Run these commands in the given Windows Terminal session. This enables opening
new tabs, splits, etc. in already running Windows Terminal windows.

  • If window-id is 0, run the given commands in the current window.
  • If window-id is a negative number, or the reserved name new, run the
    commands in a new Terminal window.
  • If window-id is the ID or name of an existing window, then run the
    commandline in that window.
  • If window-id is not the ID or name of an existing window, create a new
    window. That window will be assigned the ID or name provided in the
    commandline. The provided subcommands will be run in that new window.
  • If window-id is omitted, then obey the value of windowingBehavior when
    determining which window to run the command in.

Before this PR, I think we didn't actually properly support assigning
the id with wt -w 12345. If 12345 didn't exist, it would make a new
window, but just assign it the next id, not assign it 12345.

References

Validation Steps Performed

Ran tests
Messed with naming windows, working as expected.

Closes https://github.com/microsoft/terminal/projects/5#card-51431478

**Original Pull Request:** https://github.com/microsoft/terminal/pull/9300 **State:** closed **Merged:** Yes --- This finishes the implementation of `--window` to also accept a string as the "name" of the window. So you can say ```sh wt -w foo new-tab wt -w foo split-pane ``` and have both those commands execute in the same window, the one named "foo". This is just slightly more ergonomic than manually using the IDs of windows. In the future, I'll be working on renaming windows, and displaying these names. > #### `--window,-w <window-id>` > Run these commands in the given Windows Terminal session. This enables opening > new tabs, splits, etc. in already running Windows Terminal windows. > * If `window-id` is `0`, run the given commands in _the current window_. > * If `window-id` is a negative number, or the reserved name `new`, run the > commands in a _new_ Terminal window. > * If `window-id` is the ID or name of an existing window, then run the > commandline in that window. > * If `window-id` is _not_ the ID or name of an existing window, create a new > window. That window will be assigned the ID or name provided in the > commandline. The provided subcommands will be run in that new window. > * If `window-id` is omitted, then obey the value of `windowingBehavior` when > determining which window to run the command in. Before this PR, I think we didn't actually properly support assigning the id with `wt -w 12345`. If `12345` didn't exist, it would make a new window, but just assign it the next id, not assign it 12345. ## References * #4472, #8135 * https://github.com/microsoft/terminal/projects/5 ## Validation Steps Performed Ran tests Messed with naming windows, working as expected. Closes https://github.com/microsoft/terminal/projects/5#card-51431478
claunia added the pull-request label 2026-01-31 09:22:34 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#27539