Windows Terminal command line arguments (2023)

  • Article
  • 15 minutes to read

You can usewt.exeto open a new instance of Windows Terminal from the command line. You can also use the execution aliasweightinstead of this.

note

Building Windows Terminal from source codeGitHub, you can open this build withwtd.exeorweight.

Windows Terminal command line arguments (1)

command line syntax

DieweightThe command line accepts two types of values:optionsandcommands.optionsare a list of flags and other parameters that can control the behavior ofweightcommand line as a whole.commandsSpecify the action or a semicolon-separated list of actions to implement. If no command is specified, the command is assumed to benew windowBy default.

wt [options] [command ; ]

note

The behavior ofwt.exeCommand can be influenced by thewindowingBehavior property. This setting can be reset to the default between opening a new window or opening a new tab.

To display a help message with the available command line arguments, type:wt-h,wt --help,wt -?, orww /?.

options and commands

Below is the full list of supported commands and options for theweightcommand line.

possibilitydescription
--Help,-h,-?,/?Displays the help message.
- maximized,-MStarts the terminal maximized.
--full screen,-FStarts the terminal in full screen mode.
--Focus,-fStarts the terminal in focus mode. Can be combined withmaximized.
--Window,-w <window ID>Launches the terminal in a specific window.

New tabcommand

commandParameterdescriptionValues
new tab,NT--profile, -p ProfilnameCreates a new tab based on the assigned profile name.Profilname
new tab,NT--start dir, -d start dirCreates a new tab based on the assigned home directory path.directory path
new tab,NTcommand lineCreates a new tab based on the assigned command line.Executable with optional commands
new tab,NT--TitleCreates a new tab with the assigned title.Text to use as tab title
new tab,NT--tab colorCreates a new tab with the assigned tab color.Hex color as #RGB or #RRGGBB

Top

If you change the title of a tab in Windows Terminal and want that title to remain, you need to enable theSuppress application titleoption by setting it toIs correct.

Split disccommand

commandParameterdescriptionValues
split disc,sp-H, --horizontal,-V, --verticalCreates a new split pane either horizontally or vertically.N/A. No additional values ​​to assign.
split disc,sp--profile, -p ProfilnameCreates a new split window based on the assigned command line profile. If this parameter is not assigned, the default profile is used.Profilname
split disc,sp--start dir, -d start dirCreates a new split pane based on the assigned home directory path. If this parameter is not assigned, the default startup directory is used.directory path
split disc,sp--TitleCreates a new pane with the assigned title.Text to use as tab title
split disc,sp--tab colorCreates a new split pane with the assigned tab color.Hex color as #RGB or #RRGGBB
split disc,sp--size, -s sizeCreates a new split pane of the assigned size.Float specifying the portion of the parent range to use, represented by a decimal number. For example,.4to represent 40% of the parent area.
split disc,spcommand lineCreates a new split pane based on the assigned command line.Executable with optional commands
split disc,sp--duplicate, -DCreates a new split pane that is a duplicate of the current pane.N/A. No additional values ​​to assign.

focus tabcommand

commandParameterdescriptionValues
focus tab,ft--target, -t tab-indexFocuses on a specific tab according to its tab index number.Tab index as an integer

Move-Focuscommand

commandParameterdescriptionValues
movement focus,mfDirectionMove the focus between the windows in the indicated direction.hoch,Low,links, orto the rightvalues ​​accepted.

note

If you open Windows Terminal from cmd (Command Prompt) and want to use your custom "cmd" profile settings, you must use the commandwt -p cmd. Otherwise you runOriginallyProfile settings, just usewt cmd.

Examples of command line arguments

The commands may vary slightly depending on the command line used.

Passing an argument to the standard shell

Invoke to launch an instance of Windows Terminal and run a commandwt.exefollowed by your command.

Here's an example of calling Windows Terminal to pass aRingCommand argument to echo an IP address:

wt ping on learn.microsoft.com

Here is an example of calling Windows Terminal to open a new tab with a PowerShell command line and confirm the callstart serviceCommand and open another new tab with Windows command prompt open/kDirectory:

wt new-tab PowerShell -c Start-Dienst ; new-tab cmd /k dir

Target a specific window

Below are examples of how to target specific windows using--window,-wPossibility.

  • command prompt
  • Power Shell
  • Linux
// Open a new tab with the default profile in the current window wt -w 0 nt// Open a new tab in a new window with the default profile wt -w -1 nt// Open a new tab in the first created terminal window with the default profile wt -w 1 nt// In the terminal window, open a new tab called foo with the default profile. If foo doesn't exist, create a new window named foo.wt -w foo nt

Open a new profile instance

In this case, to open a new terminal instance, the command will open the profile named "Ubuntu-18.04", type:

  • command prompt
  • Power Shell
  • Linux
wt -p "Free-18.04"

Die-pFlag is used to specify the Windows Terminal profile to open. Replace "Ubuntu-18.04" with the name of any terminal profile you have installed. This always opens a new window. Windows Terminal is not yet able to open new tabs or panes in an existing instance.

Target a directory

To specify the folder to use as the console startup directory, in this case the d:\ directory, type:

  • command prompt
  • Power Shell
  • Linux
wt -d d:\

Multiple tabs

Type the following to open a new multi-tabbed terminal instance:

  • command prompt
  • Power Shell
  • Linux
weight ; ;

Type the following to open a new terminal instance with multiple tabs, in this case a Command Prompt profile and a PowerShell profile:

  • command prompt
  • Power Shell
  • Linux
wt -p "command prompt" ; new-tab -p "Windows PowerShell"

Multiple slices

To open a new terminal instance with a tab with three panes running a Command Prompt profile, a PowerShell profile, and your default profile with a WSL command line, type:

  • command prompt
  • Power Shell
  • Linux
wt -p "command prompt" ; split-pane -p "Windows PowerShell" ; split-pane -H wsl.exe

Die-Hflag (or--horizontal) indicates that the panes should be split horizontally. the-Vflag (or--vertical) indicates that the panes should be split vertically.

Multiple tabs and areas

Dienew tabandsplit discCommands can be sequenced to get multiple tabs, each with split windows. To open a new terminal instance with two tabs, each with two windows running a command prompt and a WSL command line, type the following, with each tab in a different directory:

  • command prompt
  • Power Shell
  • Linux
wt -p "command prompt" ; split-pane -V wsl.exe ; new-tab -d c:\ ; split-pane -H -d c:\wsl.exe

area title

To open a new terminal instance with custom titles for each terminal pane, use the--TitleDispute. To set the title of each pane when opening multiple tabs, type:

  • command prompt
  • Power Shell
  • Linux
wt --title tabname1 ; new-tab -p "Ubuntu-18.04" --title tabname2

Panels on the same tab can have different titles that affect the tab title depending on which panel has focus. To name independent areas, you can set the title after dividing the areas by typing:

  • command prompt
  • Power Shell
  • Linux
wt --title pane1 ; split-pane -p "prompt" --title pane2

Use application title

To open a new terminal instance that allows applications inside it to set the tab title by sending title change messages, use the--useApplicationTitleFlag. To suppress these messages, use the--suppressApplicationTitleFlag. If none of these flags are provided, the behavior is inherited from the profile settings. To open a titled tabtab namewhich will not be overwritten by the application, type:

  • command prompt
  • Power Shell
  • Linux
wt --title Registerkartenname --suppressApplicationTitle

tab color

To open a new terminal instance with custom tab colors, use the--tab colorDispute. This argument overrides the value defined in the profile, but can also be overridden with the tab color picker. The following example creates a new terminal with two different colored tabs:

  • command prompt
  • Power Shell
  • Linux
wt --tabColor #009999 ; new-tab --tabColor #f59218

When--tab coloris set for a tab, it is mapped to the first pane of that tab. Therefore, in a multi-pane tab, the color is applied only when the first pane has focus. To set the tab color for additional panels, you need to add the--tab colorparameters forsplit discalso subcommand. The following example creates a tab with two panes, with the tab colors set for each pane:

wt new-tab --tabColor '#009999' `; split window --tabColor '#f59218'

color scheme

To open a new terminal instance with a specific color scheme (instead of thecolor schemeset in profile), use the--Color schemeDispute. This argument overrides the value defined in the profile.

  • command prompt
  • Power Shell
  • Linux
wt --colorScheme Vintage ; split-pane --colorScheme "Tango Light"

tab focus

To open a new terminal instance with a specific tab in focus, use the-tflag (or--Goal) along with the tab index number. How to open your default profile on the first tab and the "Ubuntu-18.04" profile on the second tab (-t 1), enter:

  • command prompt
  • Power Shell
  • Linux
weight ; new-tab -p "Ubuntu-18.04" ; Focus tab -t 1

Examples of multiple PowerShell commands

Windows Terminal uses the semicolon character;as a delimiter to separate commands in theweightcommand line. Unfortunately, PowerShell uses that too;as a command separator. To get around this, you can use the following tricks to run multipleweightCommands from PowerShell. All of the following examples create a new terminal window with three panes - one with Command Prompt, one with PowerShell, and the last with WSL.

The following examples do not useBeginningto run the command line. Instead, there are two other methods to bypass the command line:

  • Just escape the semicolons so thatPower Shellignore them and forward them directlyweight.
  • Use--%, so PowerShell treats the rest of the command line as arguments to the application.
wt new-tab "cmd" `; split-pane -p "Windows PowerShell" `; split-pane -H wsl.exe
wt --% new-tab cmd ; split-pane -p "Windows PowerShell" ; split-pane -H wsl.exe

In both examples, the newly created Windows terminal window creates the window by correctly parsing all command line arguments provided.

However, these methods areNotis currently recommended because PowerShell waits for the newly created terminal window to close before returning control to PowerShell. By default, PowerShell always waits for Windows Store applications (like Windows Terminal) to close before returning to the command prompt. Note that this is different from the behavior of the command prompt, which immediately returns to the command prompt.

Top Articles
Latest Posts
Article information

Author: Cheryll Lueilwitz

Last Updated: 12/27/2022

Views: 6634

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Cheryll Lueilwitz

Birthday: 1997-12-23

Address: 4653 O'Kon Hill, Lake Juanstad, AR 65469

Phone: +494124489301

Job: Marketing Representative

Hobby: Reading, Ice skating, Foraging, BASE jumping, Hiking, Skateboarding, Kayaking

Introduction: My name is Cheryll Lueilwitz, I am a sparkling, clean, super, lucky, joyous, outstanding, lucky person who loves writing and wants to share my knowledge and understanding with you.