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) 40 Windows Commands you NEED to know (in 10 Minutes)

  • 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) The Command Line Arguments using Windows' Command.com Terminal Window : Intro to Programming Java

  • 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) How to view command line arguments for a running app on Windows 10

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 are the 6 commands in cmd? ›

Basic CMD Commands
  • #2) Mkdir. This command is used when subdirectories are to be created within the directories. ...
  • #3) REN: Rename. ...
  • #4) ASSOC: Fix File Associations. ...
  • #8) SYSTEMINFO: System Information. ...
  • #11) CHKDSK: Check Disk. ...
  • #13) ATTRIB: Change File Attributes. ...
  • #15) Network Statistics NETSTAT. ...
  • #17) PING: Send Test Packets.
Dec 5, 2022

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.

How do you write codes in command line arguments? ›

Let's see the example of command line arguments where we are passing one argument with file name.
  1. #include <stdio.h>
  2. void main(int argc, char *argv[] ) {
  3. printf("Program name is: %s\n", argv[0]);
  4. if(argc < 2){
  5. printf("No argument passed through command line.\n");
  6. }
  7. else{
  8. printf("First argument is: %s\n", argv[1]);

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 %% 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? ›

== Perform the command if the two strings are equal. /

What are cool things you can do in CMD? ›

5 Fun Tricks You Can Do in Command Prompt
  • Customize Your Look. You may know this one already, as it can be a great tool to play around with for accessibility purposes. ...
  • Watch Star Wars on Command Prompt. ...
  • More Telnet Fun: Command Prompt Aquarium. ...
  • Change the Window Title. ...
  • Trace Where Your Data Goes.
Sep 24, 2022

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 most powerful command in cmd? ›

One of the most powerful tools in the CMD command library is the ASSOC command. Your computer associates certain file extensions with certain programs. This is how your computer knows to open Adobe when you double click a PDF file, or Microsoft Word when you double click a DOC file.

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 is the difference between $() and ${}? ›

$() means: "first evaluate this, and then evaluate the rest of the line". On the other hand ${} expands a variable.

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 you write a command line script? ›

Let us understand the steps in creating a Shell Script:
  1. Create a file using a vi editor(or any other editor). Name script file with extension . sh.
  2. Start the script with #! /bin/sh.
  3. Write some code.
  4. Save the script file as filename.sh.
  5. For executing the script type bash filename.sh.
Dec 31, 2022

What is $$ in shell? ›

$$ is the pid (process id) of the shell interpreter running your script. It's different for each process running on a system at the moment, but over time the pid wraps around, and after you exit there will be another process with same pid eventually.As long as you're running, the pid is unique to you.

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.

How do I list commands in terminal? ›

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. Use -l flag to list with detailed information.

Is Windows Terminal 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)).

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.

How do I run R in Windows terminal? ›

Starting R

If R has been installed properly, simply entering R on the command line of a terminal should start the program. In Windows, the program is typically specified as the action performed when clicking on an icon.

How to list all folders and subfolders in CMD? ›

Steps
  1. Open File Explorer in Windows. ...
  2. Click in the address bar and replace the file path by typing cmd then press Enter.
  3. This should open a black and white command prompt displaying the above file path.
  4. Type dir /A:D. ...
  5. There should now be a new text file called FolderList in the above directory.

How to create a batch file to run CMD? ›

To create a Windows batch file, follow these steps:
  1. Open a text file, such as a Notepad or WordPad document.
  2. Add your commands, starting with @echo [off], followed by, each in a new line, title [title of your batch script], echo [first line], and pause.
  3. Save your file with the file extension BAT, for example, test.
Jul 19, 2022

What does it mean when someone says 1 1 3? ›

“1 + 1 = 3 (or more)” is an important design effect described by Josef Albers and Edward Tufte. It means that two elements in close proximity cause a visible interaction: Figure: 1 + 1 = 3. (Copyright Al Globus.) This interaction can result in perceiving information that is not there.

What does it mean to be 1 3? ›

One third is equivalent to the fraction: 1/3.

What is the meaning of a 1 3? ›

Definitions of one-third. one of three equal parts of a divisible whole. synonyms: third, tierce. type of: common fraction, simple fraction.

What does %% I mean? ›

%%i is simply the loop variable. This is explained in the documentation for the for command, which you can get by typing for /? at the command prompt.

What is %% F in batch script? ›

By default, /F breaks up the command output at each blank space, and any blank lines are skipped. You can override this default parsing behavior by specifying the "options" parameter.

How to create variable in cmd? ›

Syntax SET variable SET variable=string SET "variable=string" SET "variable=" SET /A "variable=expression" SET /P variable=[promptString] SET " Key variable : A new or existing environment variable name e.g. _num string : A text string to assign to the variable.

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)).

How do I configure Windows Terminal? ›

  1. Install. Install Windows Terminal. ...
  2. Set your default terminal application. Important. ...
  3. Set your default terminal profile. ...
  4. Add new profiles. ...
  5. Open a new tab. ...
  6. Invoke the command palette. ...
  7. Open a new pane. ...
  8. Configuration.
Oct 6, 2022

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.

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( ).

How do you trigger an execution? ›

Following are the steps of trigger execution:
  1. Load the original record or initialize on insert.
  2. Override the old record values with the new values.
  3. Execute all before triggers.
  4. Run the system & user-defined validation rules.
  5. Save the record but do not commit the record to the database.
  6. Execute all after triggers.
Jun 16, 2021

Is there a hotkey for cmd? ›

Press the Win + R keys on your keyboard, then type cmd, and press Enter on your keyboard or click/tap OK.

Videos

1. The New Windows Terminal: Command Line Just Got Better
(Pro Tech Show)
2. Command Line Arguments - CS50 Shorts
(CS50)
3. Command Line Crash Course
(freeCodeCamp.org)
4. Command Line Arguments in Python - How to Read Command Line Arguments in Python
(Coding Under Pressure)
5. Is it possible to initialize Windows Terminal with a command or batch file? | One Dev Question
(Windows Developer)
6. 10 Basic Windows Command Line Arguments || Kitty Hacks yt || command line
(KITTY HACKS YT)
Top Articles
Latest Posts
Article information

Author: Merrill Bechtelar CPA

Last Updated: 01/14/2023

Views: 6557

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Merrill Bechtelar CPA

Birthday: 1996-05-19

Address: Apt. 114 873 White Lodge, Libbyfurt, CA 93006

Phone: +5983010455207

Job: Legacy Representative

Hobby: Blacksmithing, Urban exploration, Sudoku, Slacklining, Creative writing, Community, Letterboxing

Introduction: My name is Merrill Bechtelar CPA, I am a clean, agreeable, glorious, magnificent, witty, enchanting, comfortable person who loves writing and wants to share my knowledge and understanding with you.