Edit

Share via


Using command line arguments for Windows Terminal

Use wt.exe to open a new instance of Windows Terminal from the command line. You can also use the execution alias wt instead.

Note

If you build Windows Terminal from the source code on GitHub, you can open that build by using wtd.exe or wtd.

Windows Terminal command line argument for split panes

Command line syntax

The wt command line accepts two types of values: options and commands. Options are a list of flags and other parameters that control the behavior of the wt command line as a whole. Commands provide the action, or list of actions separated by semicolons, that the command line implements. If you don't specify a command, the command line uses new-tab by default.

wt [options] [command ; ]

Note

The windowingBehavior property can affect the behavior of the wt.exe command. Adjust this setting to default between opening a new window or opening a new tab.

To display a help message that lists the available command line arguments, enter: wt -h, wt --help, wt -?, or wt /?.

Options and commands

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

Option Description
--help, -h, -?, /? Displays the help message.
--maximized, -M Launches the terminal maximized.
--fullscreen, -F Launches the terminal as full screen.
--focus, -f Launches the terminal in the focus mode. Can be combined with maximized.
--pos x,y Launches the terminal at the given position. x or y can be omitted, to use the default value from the settings.
--size c,r Launches the terminal with the specified number of columns (c) and rows (r).
--window, -w window-id Runs the given command in a specific window.

The --window parameter can be used to send commands to existing terminal windows.

window-id may either be the integer ID of a window, or the name of a window. It also accepts the following reserved values:

  • new or -1: Always run this command in a new window
  • last or 0: Always run this command in the most recently used window

If no window exists with the given window-id, then a new window will be created with that id/name.

For example, running wt -w _quake will open a new "quake window". Running that command again will open a new tab in the existing quake window.

New tab command

Use this command to create a new tab. For more information, see the newTab action.

Command Parameter Description Values
new-tab, nt --profile, -p profile-name Creates a new tab based on the profile name assigned. Profile name
new-tab, nt --startingDirectory, -d starting-directory Creates a new tab based on the starting directory path assigned. Directory path
new-tab, nt --title title Creates a new tab with the title assigned. Text to use as the tab title
new-tab, nt --tabColor hex-color Creates a new tab with the tab color assigned. Hex color as #RGB or #RRGGBB
new-tab, nt --suppressApplicationTitle Override the profile's suppressApplicationTitle setting, and set it to true
new-tab, nt --useApplicationTitle Override the profile's suppressApplicationTitle setting, and set it to false
new-tab, nt --colorScheme scheme-name Override the profile's colorScheme setting, and set it to the scheme from the settings with the name scheme-name The name of a color scheme in the settings
new-tab, nt --appendCommandLine Appends the provided command-line to the profile's default command instead of replacing it
new-tab, nt --inheritEnvironment, !--reloadEnvironment Inherit the terminal's own environment variables when creating the new session, rather than creating a fresh environment block. This defaults to set when a commandline is passed.
new-tab, nt commandline Creates a new tab based on the command line assigned. Executable with optional arguments

Tip

If you change the title of a tab in Windows Terminal and want that title to persist, you must enable the suppressApplicationTitle option by setting it to true.

Split-pane command

Use this command to create a new split pane. For more information, see the splitPane action.

Command Parameter Description Values
split-pane, sp -H, --horizontal, -V, --vertical Creates a new split window pane either horizontally or vertically. N/A. No additional values to assign.
split-pane, sp --profile, -p profile-name Creates a new split window pane based on the assigned command line profile. If you don't assign this parameter, the default profile is used. Profile name
split-pane, sp --startingDirectory, -d starting-directory Creates a new split window pane based on the assigned starting directory path. If you don't assign this parameter, the default starting directory is used. Directory path
split-pane, sp --title Creates a new split window pane with the assigned title. Text to use as the tab title
split-pane, sp --tabColor Creates a new split window pane with the assigned tab color. Hex color as #RGB or #RRGGBB
split-pane, sp --size, -s size Creates a new split window pane with the assigned size. Float that specifies the portion of the parent pane to use represented by a decimal. For example, .4 to represent 40% of the parent pane.
split-pane, sp commandline Creates a new split window pane based on the assigned command line. Executable with optional commands
split-pane, sp --duplicate, -D Creates a new split window pane that duplicates the current pane. N/A. No additional values to assign.
split-pane, sp --suppressApplicationTitle Overrides the profile's suppressApplicationTitle setting, and sets it to true.
split-pane, sp --useApplicationTitle Overrides the profile's suppressApplicationTitle setting, and sets it to false.
split-pane, sp --colorScheme scheme-name Overrides the profile's colorScheme setting, and sets it to the scheme from the settings with the name scheme-name. The name of a color scheme in the settings

Focus-tab command

Use this command to focus a specific tab within the window. For more information, see the switchToTab action.

Command Parameter Description Values
focus-tab, ft --target, -t tab-index Focuses on a specific tab according to its tab index number. Tab index as an integer

Move-focus command

Use this command to move focus within the window. For more information, see the moveFocus action.

Command Parameter Description Values
move-focus, mf <direction> Move focus between panes. See below for accepted direction values

Accepted direction values

  • up, down, left, or right move focus in the given direction.
  • first moves focus to the first leaf pane in the tree.
  • previous moves the focus to the most recently used pane before the current pane.
  • nextInOrder, previousInOrder moves the focus to the next or previous pane in order of creation.

Move-pane command

Use this command to move a pane within the window. For more information, see the movePane action.

Command Parameter Description Values
move-pane, mp --tab,-t <index> Move the active pane to the given tab in the window The zero-indexed index of the tab to move the pane to.

Swap-pane command

Use this command to swap the position of two panes within the window. See also the swapPane action.

Command Parameter Description Values
swap-pane <direction> Swap the pane with the pane in the given direction See below for accepted direction values

Accepted direction values (these values are the same as the move-focus sub command):

  • up, down, left, or right: Swap the active pane with the one in the given direction.
  • first: Swap the active pane with the first leaf pane in the tree.
  • previous: Swap the active pane with the most recently used pane before the current pane.
  • nextInOrder, previousInOrder: Swap the active pane with the next or previous pane in order of creation.

Command line argument examples

Commands might vary slightly depending on which command line you're using.

Passing an argument to the default shell

To start an instance of Windows Terminal and have it execute a command, call wt.exe followed by your command.

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

wt ping learn.microsoft.com

Here's an example of calling Windows Terminal to open a new tab with a PowerShell command line, confirming to call the Start-Service command, and opening another new tab with Windows Command Prompt open to the /k directory:

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

Target a specific window

The following examples show how to use the --window,-w option to target specific windows.

// 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

// Open a new tab in the terminal window named foo with the default profile. If foo does not exist, create a new window named foo.
wt -w foo nt

Open a new profile instance

To open a new terminal instance, such as the profile named "Ubuntu-18.04", enter:

wt -p "Ubuntu-18.04"

Use the -p flag to specify the Windows Terminal profile that you want to open. Replace "Ubuntu-18.04" with the name of any terminal profile that you installed. This command always opens a new window. To open a new shell tab in an existing (already open) instance of Windows Terminal, use: wt -w [window id](#options-and-commands) [executable name]. For example, wt -w 0 cmd opens a Command Prompt shell in the most recent instance of Windows Terminal. If you're launching a profile (shell executable combined with color scheme, title, command, and other settings that control how it interacts with the console session), you must use the profile name in the command: wt -w 0 -p "Profile Name".

Target a directory

To specify the folder that the console uses as the starting directory, enter the following command. In this example, the starting directory is the d:\ directory:

wt -d d:\

Multiple tabs

To open a new terminal instance with multiple tabs, enter:

wt ; ;

To open a new terminal instance with multiple tabs, in this case a Command Prompt profile and a PowerShell profile, enter:

wt -p "Command Prompt" ; new-tab -p "Windows PowerShell"

Multiple panes

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

wt -p "Command Prompt" ; split-pane -p "Windows PowerShell" ; split-pane -H wsl.exe

The -H flag (or --horizontal) indicates that you want the panes to be split horizontally. The -V flag (or --vertical) indicates that you want the panes split vertically.

Multiple tabs and panes

Sequence the new-tab and split-pane commands to get multiple tabs, each with split panes. To open a new terminal instance with two tabs, each with two panes running a Command Prompt and a WSL command line, with each tab in a different directory, enter:

wt -p "Command Prompt" ; split-pane -V wsl.exe ; new-tab -d c:\ ; split-pane -H -d c:\ wsl.exe

Pane title

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

wt --title tabname1 ; new-tab -p "Ubuntu-18.04" --title tabname2

Panes in the same tab can have different titles. The tab title reflects the title of the pane that has focus. To name independent panes, set the title after splitting the panes by entering:

wt --title pane1 ; split-pane -p "Command Prompt" --title pane2

Using application title

To open a new terminal instance that lets applications set the tab title by sending title change messages, use the --useApplicationTitle flag. To suppress these messages, use the --suppressApplicationTitle flag. If you don't provide either flag, the terminal uses the profile's settings. To open a tab with the title tabname that the application doesn't override, enter:

wt --title tabname --suppressApplicationTitle

Tab color

To open a new terminal instance with custom tab colors, use the --tabColor argument. This argument overrides the value defined in the profile, but the tab color picker can override it as well. In the following example, a new terminal is created with two tabs of different colors:

wt --tabColor #009999 ; new-tab --tabColor #f59218

When you set --tabColor for a tab, you associate it with the first pane of this tab. Hence in a tab with multiple panes, the color is applied only if the first pane is in focus. To set the tab color for additional panes, you need to add the --tabColor parameter to the split-pane subcommand as well. In the example below, a tab with two panes is created with tab colors specified for each pane:

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

Color scheme

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

wt --colorScheme Vintage ; split-pane --colorScheme "Tango Light"

Tab focus

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

wt ; new-tab -p "Ubuntu-18.04" ; focus-tab -t 1

Examples of multiple commands from PowerShell

Windows Terminal uses the semicolon character ; as a delimiter for separating commands in the wt command line. Unfortunately, PowerShell also uses ; as a command separator. To work around this issue, use the following tricks to run multiple wt commands from PowerShell. In all the following examples, a new terminal window is created with three panes - one running Command Prompt, one with PowerShell, and the last one running WSL.

The following examples don't use start to run the command line. Instead, they use two other methods of escaping the command line:

  • Only escaping the semicolons so that PowerShell ignores them and passes them straight to wt.
  • Using --%, 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 of these examples, the newly created Windows Terminal window correctly parses all the provided command-line arguments.

However, these methods aren't currently recommended. 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 prompt. This behavior is different from the behavior of Command Prompt, which returns to the prompt immediately.

Add Windows Terminal executable to your PATH

To add the Windows Terminal executable file (wt.exe) to your PATH, enable its "app execution alias" in the Manage app execution aliases page of Windows Settings. The Windows Terminal alias is turned on by default, but you might want to confirm it if you're having issues accessing it.

If you're still having trouble accessing app execution aliases, check whether your PATH contains: %LOCALAPPDATA%\Microsoft\WindowsApps. Don't attempt to make changes to C:\Program Files\WindowsApps.

Windows Settings for App Execution Aliases