Tutorial: Configure tab titles in Windows Terminal

By default, the tab title is set to the shell's title. If a tab is composed of multiple panes, the tab's title is set to that of the currently focused pane. If you want to customize what is set as the tab title, follow this tutorial.

In this tutorial, you learn how to:

  • Use the tabTitle setting
  • Set the shell's title
  • Using the suppressApplicationTitle setting

Use the tabTitle setting

The tabTitle setting allows you to define the starting title for a new instance of a shell. If it is not set, the profile name is used instead. Each shell responds to this setting differently.

Shell Behavior
PowerShell The title is set.
Command Prompt The title is set. If a command is running, it is temporarily appended to the end of the title.
Ubuntu The title is ignored, and instead set to user@machine:path
Debian The title is set.

Note

Though Ubuntu and Debian both run bash, they have different behaviors. This is to show that different distributions may have different behaviors.

Set the shell's title

A shell has full control over its own title. However, each shell sets its title differently.

Shell Command
PowerShell $Host.UI.RawUI.WindowTitle = "New Title"
Command Prompt TITLE New Title
bash* echo -ne "\033]0;New Title\a"

Note that some Linux distributions (e.g. Ubuntu) set their title automatically as you interact with the shell. If the above command doesn't work, run the following command:

export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
echo -ne '\033]0;New Title\a'

This will change the title to 'New Title'.

For easier access add this to the end of your ~/.bashrc:

settitle () {
  export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  echo -ne '\033]0;'"$1"'\a'
}

After you reopen your shell, you now can change the shell's title at any time using the following command:

settitle 'New Title'

Use the suppressApplicationTitle setting

Since a shell has control over its title, it may choose to overwrite the tab title at any time. For example, the posh-git module for PowerShell adds information about your Git repository to the title.

Windows Terminal allows you to suppress changes to the title by setting suppressApplicationTitle to true in your profile. This makes new instances of the profile set your visible title to tabTitle. If tabTitle is not set, the visible title is set to the profile's name.

Note that this decouples the shell's title from the visible title presented on the tab. If you read the shell's variable where the title is set, it may differ from the tab's title.

Resources