Windows Terminal command line arguments (2023)

  • Article
  • 15 minutes to read

You can 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 built Windows Terminal from the source code on GitHub, you can open that build using wtd.exe or wtd.

Windows Terminal command line arguments (1)

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 can control the behavior of the wt command line as a whole. Commands provide the action, or list of actions separated by semicolons, that should be implemented. If no command is specified, then the command is assumed to be new-window by default.

wt [options] [command ; ]

Note

The behavior of the wt.exe command may be affected by the windowingBehavior property. This setting can be adjusted to default between opening a new window or opening a new tab.

(Video) Customize Windows Terminal 1.0 | Using Command line Arguments

To display a help message listing 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.

OptionDescription
--help, -h, -?, /?Displays the help message.
--maximized, -MLaunches the terminal maximized.
--fullscreen, -FLaunches the terminal as full screen.
--focus, -fLaunches the terminal in the focus mode. Can be combined with maximized.
--window, -w <window-id>Launches the terminal in a specific window.

New-tab command

CommandParameterDescriptionValues
new-tab, nt--profile, -p profile-nameCreates a new tab based on the profile name assigned.Profile name
new-tab, nt--startingDirectory, -d starting-directoryCreates a new tab based on the starting directory path assigned.Directory path
new-tab, ntcommandlineCreates a new tab based on the command line assigned.Executable with optional commands
new-tab, nt--titleCreates a new tab with the title assigned.Text to use as the tab title
new-tab, nt--tabColorCreates a new tab with the tab color assigned.Hex color as #RGB or #RRGGBB

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

CommandParameterDescriptionValues
split-pane, sp-H, --horizontal, -V, --verticalCreates a new split window pane either horizontally or vertically.N/A. No additional values to assign.
split-pane, sp--profile, -p profile-nameCreates a new split window pane based on the assigned command line profile. If this parameter is not assigned, the default profile will be used.Profile name
split-pane, sp--startingDirectory, -d starting-directoryCreates a new split window pane based on the assigned starting directory path. If this parameter is not assigned, the default starting directory will be used.Directory path
split-pane, sp--titleCreates a new split window pane with the assigned title.Text to use as the tab title
split-pane, sp--tabColorCreates a new split window pane with the assigned tab color.Hex color as #RGB or #RRGGBB
split-pane, sp--size, -s sizeCreates 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, spcommandlineCreates a new split window pane based on the assigned command line.Executable with optional commands
split-pane, sp--duplicate, -DCreates a new split window pane that is a duplicate of the current pane.N/A. No additional values to assign.

Focus-tab command

CommandParameterDescriptionValues
focus-tab, ft--target, -t tab-indexFocuses on a specific tab according to it's tab index number.Tab index as an integer

Move-focus command

CommandParameterDescriptionValues
move-focus, mfdirectionMove focus between panes in the given direction.up, down, left, or right values accepted.

Note

When opening Windows Terminal from cmd (Command Prompt), if you want to use your custom "cmd" profile settings, you will need to use the command wt -p cmd. Otherwise, to run your default profile settings, just use wt cmd.

Command line argument examples

Commands may 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:

(Video) Windows Terminal: the secret to command line happiness!

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

Below are examples of how to target specific windows using the --window,-w option.

  • Command Prompt
  • PowerShell
  • Linux
// Open a new tab with the default profile in the current windowwt -w 0 nt// Open a new tab in a new window with the default profilewt -w -1 nt// Open a new tab in the first-created terminal window with the default profilewt -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, in this case the command will open the profile named "Ubuntu-18.04", enter:

  • Command Prompt
  • PowerShell
  • Linux
wt -p "Ubuntu-18.04"

The -p flag is used to specify the Windows Terminal profile that should be opened. Substitute "Ubuntu-18.04" with the name of any terminal profile that you have installed. This will always open a new window. Windows Terminal is not yet capable of opening new tabs or panes in an existing instance.

Target a directory

To specify the folder that should be used as the starting directory for the console, in this case the d:\ directory, enter:

  • Command Prompt
  • PowerShell
  • Linux
wt -d d:\

Multiple tabs

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

  • Command Prompt
  • PowerShell
  • Linux
wt ; ;

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

(Video) The Command Line Arguments using Windows' Command.com Terminal Window : Intro to Programming Java

  • Command Prompt
  • PowerShell
  • Linux
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:

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

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

Multiple tabs and panes

The new-tab and split-pane commands can be sequenced 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:

  • Command Prompt
  • PowerShell
  • Linux
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:

  • Command Prompt
  • PowerShell
  • Linux
wt --title tabname1 ; new-tab -p "Ubuntu-18.04" --title tabname2

Panes in the same tab can have different titles, which will reflect on the tab title depending on which pane has focus. To name independent panes, you can set the title after splitting the panes by entering:

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

Using application title

To open a new terminal instance allowing applications within it to set the tab title by sending title change messages, use the --useApplicationTitle flag. To suppress these messages, use the --suppressApplicationTitle flag. If none of these flags are provided, the behavior is inherited from the profile's settings. To open a tab with title tabname that will not be overridden by the application, enter:

(Video) 40 Windows Commands you NEED to know (in 10 Minutes)

  • Command Prompt
  • PowerShell
  • Linux
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 can be overridden as well using the tab color picker. In the following example, a new terminal is created with two tabs of different colors:

  • Command Prompt
  • PowerShell
  • Linux
wt --tabColor #009999 ; new-tab --tabColor #f59218

When --tabColor is set for a tab, it is associated with the first pane of this tab. Hence in a tab with multiple panes, the color will be applied only if the first pane is in focus. To set the tab color for additional panes, you will 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.

  • Command Prompt
  • PowerShell
  • 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 -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:

  • Command Prompt
  • PowerShell
  • Linux
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, you can 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 do not use start to run the command line. Instead, there are two other methods of escaping the command line:

  • Only escaping the semicolons so that PowerShell will ignore them and pass them straight to wt.
  • Using --%, so PowerShell will treat 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 will create the window by correctly parsing all the provided command-line arguments.

(Video) Command Line Arguments - CS50 Shorts

However, these methods are not recommended currently, as PowerShell will wait for the newly-created terminal window to be closed before returning control to PowerShell. By default, PowerShell will always wait for Windows Store applications (like Windows Terminal) to close before returning to the prompt. Note that this is different than the behavior of Command Prompt, which will return to the prompt immediately.

FAQs

How do I use command line arguments in Windows? ›

A command line argument is simply anything we enter after the executable name, which in the above example is notepad.exe. So for example, if we launched Notepad using the command C:\Windows\System32\notepad.exe /s, then /s would be the command line argument we used.

How do you pass a command line argument in terminal? ›

Command-line arguments are given after the name of the program in command-line shell of Operating Systems. To pass command line arguments, we typically define main() with two arguments : first argument is the number of command line arguments and second is list of command-line arguments.

What are command line arguments in terminal? ›

Command-line arguments are simple parameters that are given on the system's command line, and the values of these arguments are passed on to your program during program execution. When a program starts execution without user interaction, command-line arguments are used to pass values or files to it.

What is %% A in batch? ›

Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.

What is the difference between $* and $@? ›

There is no difference if you do not put $* or $@ in quotes. But if you put them inside quotes (which you should, as a general good practice), then $@ will pass your parameters as separate parameters, whereas $* will just pass all params as a single parameter.

What is $@ in shell script? ›

$@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them.

What is $() in terminal? ›

$() is a command substitution

It turns out, $() is called a command substitution. The command in between $() or backticks (“) is run and the output replaces $() . It can also be described as executing a command inside of another command.

What does $# mean in bash? ›

$# is a special variable in bash , that expands to the number of arguments (positional parameters) i.e. $1, $2 ... passed to the script in question or the shell in case of argument directly passed to the shell e.g. in bash -c '...' .... .

What is command line argument explain with example? ›

A command-line argument is an information that directly follows the program's name on the command line when it is executed. To access the command-line arguments inside a Java program is quite easy. They are stored as strings in the String array passed to main( ).

What is %% R in batch command? ›

/r - iterate through the folder and all subfolders, i.e. recursively. %%I - placeholder for a path/filename. The above command simply lists all files in the current folder and all subfolders. Follow this answer to receive notifications.

What does %~ 1 mean? ›

%1 is the first argument form the invoking command line. If the passed argument has quotes around it, %1 includes the quotes. Where as, %~1 provides the argument value with quotes removed. Helpful reference here. Follow this answer to receive notifications.

What does == mean in cmd? ›

Equality between two variables/values (==)

There are many times when we need to ask the computer if two variables contain an "equal" value (e.g., x == y), or if one variable contains a value equal to a known constant (e.g., x == 5). Equality is represented in the program using the DOUBLE EQUAL signs operator.

What are the 7 basic commands? ›

Seven basic commands all dogs should know: Name Recognition, Sit, Down, Heel, Come, Place and Leave It.

Why do hackers use command line? ›

A graphical user interface permits the user to interact with a computer by using a mouse or keyboard to control and make changes to visual elements on the computer's screen. Hackers enjoy working with a command line interface, such in Linux, because it gives them greater access over the system the exploit. Hackers have ...

Why is cmd so powerful? ›

Command prompt interfaces can be powerful and succinct. Some tools that aren't available through the graphical user interface (GUI) can be accessed through the command prompt. It also offers superior automation through scripting, but mastering the commands can be challenging.

What is the difference between $$ and $!? ›

18: What is the difference between $$ and $!?

$$ gives the process id of the currently executing process whereas $! Shows the process id of the process that recently went into the background.

What is the difference between == and === *? ›

The main difference between the == and === operator in javascript is that the == operator does the type conversion of the operands before comparison, whereas the === operator compares the values as well as the data types of the operands.

What are $( and $(( )) in bash? ›

$(...) is an expression that starts a new subshell, whose expansion is the standard output produced by the commands it runs. This is similar to another command/expression pair in bash : ((...)) is an arithmetic statement, while $((...)) is an arithmetic expression. Follow this answer to receive notifications.

What does $$ mean in shell? ›

From Advanced Bash-Scripting Guide: $$ is the process ID (PID) of the script itself. $BASHPID is the process ID of the current instance of Bash.

What is $? == 0 in shell script? ›

$? is the exit status of the most recently-executed command; by convention, 0 means success and anything else indicates failure. That line is testing whether the grep command succeeded. The grep manpage states: The exit status is 0 if selected lines are found, and 1 if not found.

What is $? 0 in bash? ›

After a script terminates, a $? from the command-line gives the exit status of the script, that is, the last command executed in the script, which is, by convention, 0 on success or an integer in the range 1 - 255 on error. Example 6-1. exit / exit status. #!/bin/bash echo hello echo $?

How do I set up command line arguments in Windows 10? ›

Right-click on the shortcut and choose Properties. In the target-field add command line parameters after the program file name. For example: %SystemRoot%\system32\notepad.exe C:\test1.

Can I write code from command line? ›

A CMD script does the same thing as if you typed commands into the CMD window. If you want to do something on a regular basis, such as telling Windows to turn off your computer after an hour, you can write a script and then you can activate the script whenever you want to run it.

How do I list commands in terminal? ›

ls. The ls command stands for List. We can use it to list all the contents of the specified directory; if no path is specified, it will list everything in the current directory. Use -a flag to list hidden files and directories.

Can I do everything in terminal? ›

In a terminal you can write commands for the computer to follow. It allows you to do everything (and more) that you normally can do with an interface.

What does $* Do bash? ›

It's a space separated string of all arguments. For example, if $1 is "hello" and $2 is "world", then $* is "hello world".

What does $1 do in bash? ›

$1 - The first argument sent to the script. $2 - The second argument sent to the script. $3 - The third argument... and so forth. $# - The number of arguments provided.

What does %% do in bash? ›

In your case ## and %% are operators that extract part of the string. ## deletes longest match of defined substring starting at the start of given string. %% does the same, except it starts from back of the string.

What is the first argument in command line? ›

The first parameter to main, argc, is the count of the number of command line arguments. Actually, it is one more than the number of arguments, because the first command line argument is the program name itself! In other words, in the gcc example above, the first argument is "gcc".

What is an example of a command line? ›

The MS-DOS operating system and the command shell in the Windows operating system are examples of command-line interfaces. In addition, programming language development platforms such as Python can support command-line interfaces.

How do I Run a command line argument? ›

You can test command line arguments by running an executable from the "Command Prompt" in Windows or from the "DOS prompt" in older versions of Windows. You can also use command line arguments in program shortcuts, or when running an application by using Start -> Run. This will start notepad with a blank document.

How do I trigger in cmd? ›

To run commands on your computers: 1 - Create an account at triggercmd.com. 2 - Install the TRIGGERcmd agent on your computer. 3 - Setup commands using the agent software. 4 - Trigger those commands with Microsoft Power Automate.

Is Windows Terminal the same as Command Prompt? ›

Windows Terminal is a modern host application for the command-line shells you already love, like Command Prompt, PowerShell, and bash (via Windows Subsystem for Linux (WSL)).

Does Windows have a CLI? ›

The command line interface is a program on your computer that allows you to create and delete files, run programs, and navigate through folders and files. On a Mac, it's called Terminal, and on Windows, it's Command Prompt.

Videos

1. Project signature verification with GPG and ansible-sign
(Ansible Pilot)
2. How to use command line arguments in a Python script with sys.argv and argparse
(IDG TECHtalk)
3. What are command line arguments (argc and argv)?
(CodeVault)
4. Command Line Arguments in Python - How to Read Command Line Arguments in Python
(Coding Under Pressure)
5. Command Line Arguments in Java
(Neso Academy)
6. Command Line Crash Course
(freeCodeCamp.org)
Top Articles
Latest Posts
Article information

Author: Sen. Ignacio Ratke

Last Updated: 01/27/2023

Views: 5927

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Sen. Ignacio Ratke

Birthday: 1999-05-27

Address: Apt. 171 8116 Bailey Via, Roberthaven, GA 58289

Phone: +2585395768220

Job: Lead Liaison

Hobby: Lockpicking, LARPing, Lego building, Lapidary, Macrame, Book restoration, Bodybuilding

Introduction: My name is Sen. Ignacio Ratke, I am a adventurous, zealous, outstanding, agreeable, precious, excited, gifted person who loves writing and wants to share my knowledge and understanding with you.