06-Terminal Advanced
06-Terminal Advanced
com/docs/terminal/advanced
TOPICS Advanced
(https://vscode.dev/github/microsoft/vscode-docs/blob/main/docs/terminal/advanced.md)
Terminal Advanced
Visual Studio Code's integrated terminal has many advanced features and settings, such as Unicode and
emoji support, custom keyboard shortcuts, and automatic replies. This topic explains these advanced
features in detail. If you are new to VS Code or the integrated terminal, you may want to review the
Terminal Basics (/docs/terminal/basics) topic first.
Persistent sessions
• Process reconnection: When reloading a window (for example, after installing an extension),
reconnect to the previous process and restore its content.
• Process revive: When restarting VS Code, a terminal's content is restored and the process is
relaunched using its original environment.
As an embedded application, the integrated terminal should intercept some, but not all, keyboard
shortcuts dispatched within VS Code.
The configurable
! (vscode://settings/terminal.integrated.commandsToSkipShell)terminal.integrated.commandsToSkipShell
setting determines which command's keyboard shortcuts should always "skip the shell" and instead be
handled by VS Code's keyboard shortcut system. By default, it contains a hard-coded list of commands
that are integral to the VS Code experience but you can add or remove specific commands:
{ Copy
"terminal.integrated.commandsToSkipShell": [
// Ensure the toggle sidebar visibility keyboard shortcut skips the shell
"workbench.action.toggleSidebarVisibility",
// Send quick open's keyboard shortcut to the shell
"-workbench.action.quickOpen",
]
}
Look at the
! (vscode://settings/terminal.integrated.commandsToSkipShell)terminal.integrated.commandsToSkipShell
setting details to see the complete list of default commands.
Tip:
! (vscode://settings/
terminal.integrated.sendKeybindingsToShell)terminal.integrated.sendKeybindingsToShell
can be configured to override
! (vscode://settings/
terminal.integrated.commandsToSkipShell)terminal.integrated.commandsToSkipShell
and dispatch most keyboard shortcuts to the shell. Note that this will disable keyboard shortcuts like
Ctrl+F to open find (/docs/terminal/basics#find) though.
Chords
Chord keyboard shortcuts are made up of two keyboard shortcuts, for example Ctrl+K followed by
Ctrl+C to change the line to a comment. Chords always skip the shell by default but can be disabled with
! (vscode://settings/terminal.integrated.allowChords)terminal.integrated.allowChords .
{ Copy
"key": "cmd+k",
"command": "-workbench.action.terminal.clear"
}
Additionally, this keyboard shortcut will be overridden automatically if any extensions contribute Cmd+K
keyboard shortcuts due to how keyboard shortcut priority works. To re-enable the Cmd+K clear keyboard
shortcut in this case, you can redefine it in user keyboard shortcuts, which have a higher priority than
extension keyboard shortcuts:
{ Copy
"key": "cmd+k",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProce
ssSupported"
}
Mnemonics
Using mnemonics to access VS Code's menu (for example, Alt+F for File menu) is disabled by default in
the terminal as these key events are often important hotkeys in shells. Set
! (vscode://settings/terminal.integrated.allowMnemonics)terminal.integrated.allowMnemonics to enable
mnemonics, but note that this will disallow any Alt key events to go to the shell. This setting does
nothing on macOS.
For example, the sequence below jumps over the word to the left of the cursor ( Ctrl+Left ) and then
presses Backspace :
{ Copy
"key": "ctrl+u",
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u001b[1;5D\u007f"
}
}
The sendSequence command only works with the \u0000 format for using characters via their character
code (not \x00 ). Read more about these hex codes and terminal sequences in the following resources:
Confirmation dialogs
In order to avoid unnecessary output and user prompts, the terminal does not show warning dialogs when
processes exit. If warnings are desirable, they can be configured with the following settings:
• ! (vscode://settings/terminal.integrated.confirmOnExit)terminal.integrated.confirmOnExit -
Controls whether to confirm when the window closes if there are active debug sessions.
• ! (vscode://settings/terminal.integrated.confirmOnKill)terminal.integrated.confirmOnKill -
Controls whether to confirm killing terminals when they have child processes.
• ! (vscode://settings/terminal.integrated.showExitAlert)terminal.integrated.showExitAlert -
Controls whether to show the alert "The terminal process terminated with exit code" when exit code
is non-zero.
Auto replies
The terminal can automatically provide a configurable input response to the shell if an exact sequence of
output is received. The most common use case is to automatically reply to a prompt when hitting Ctrl+C
in batch scripts that ask whether the user wants to terminate the batch job. To automatically dismiss this
message, add this setting:
{ Copy
"terminal.integrated.autoReplies": {
"Terminate batch job (Y/N)": "Y\r"
}
}
Notice that the \r character used here means Enter , and much like custom sequence keyboard
shortcuts, this feature supports sending escape sequences to the shell.
No auto replies are configured by default as providing shell input should be an explicit action or
configuration by the user.
The terminal has both Unicode and emoji support. When these characters are used in the terminal, there
are some caveats to that support:
• Some Unicode symbols have ambiguous width that may change between Unicode versions.
Currently we support Unicode version 6 and 11 widths, which can be configured with the
! (vscode://settings/terminal.integrated.unicodeVersion)terminal.integrated.unicodeVersion
setting. The version specified should match the Unicode version used by the shell/operating system,
otherwise there could be rendering issues. Note that the Unicode version of the shell/OS may not
match the font's actual width.
• Some emojis comprised of multiple characters may not render correctly, for example, skin tone
modifiers.
• Emoji support is limited on Windows.
Image support
Images in the terminal work provided they use either the Sixel or iTerm inline image protocols. This feature
is disabled by default and can be enabled with the
! (vscode://settings/terminal.integrated.enableImages)terminal.integrated.enableImages setting.
Current limitations:
• Serialization does not work, so reloading a terminal will not retain any images (jerch/xterm-addon-
image#47 (https://github.com/jerch/xterm-addon-image/issues/47)).
• Copying the selection as HTML does not include the selected image (jerch/xterm-addon-image#50
(https://github.com/jerch/xterm-addon-image/issues/50)).
• Animated gifs don't work (jerch/xterm-addon-image#51 (https://github.com/jerch/xterm-addon-
image/issues/51)).
• Images that are shorter than a cell will not work properly, this is a design flaw with the sequences
and also occurs in XTerm (https://github.com/microsoft/vscode/
issues/183840#issuecomment-1569345048).
Process environment
The process environment of the application running within the terminal is influenced by various settings
and extensions and can cause the output in the VS Code terminal to look different than in other terminals.
Environment inheritance
When VS Code is opened, it launches a login shell environment in order to source a shell environment.
This is done because developer tools are often added to the $PATH in a shell launch script like
~/.bash_profile . By default, the terminal inherits this environment, depending on your profile shell
arguments (/docs/terminal/profiles#_configuring-profiles), and means that multiple profile scripts may
have run, which could cause unexpected behavior.
This environment inheritance can be disabled on macOS and Linux via the
! (vscode://settings/terminal.integrated.inheritEnv)terminal.integrated.inheritEnv setting.
Value Behavior
on Always set $LANG to the most commonly desired value. The chosen value is based on
the operating system locale (falling back to en-US ) with UTF-8 encoding.
auto Set $LANG similar to the on behavior if $LANG is not properly configured (is not set to a
(default) UTF or EUC encoding).
If an extension changes the terminal environment, any existing terminals will be relaunched if it is safe to
do so, otherwise a warning will show in the terminal status. More information about the change can be
viewed in the hover, which also includes a relaunch button.
An open source project called winpty (https://github.com/rprichard/winpty) was created to try to fix this
issue by providing an emulation/translation layer between a Unix-style terminal and a Windows console. VS
Code's terminal was originally implemented using only winpty. This was great at the time, but in 2018,
Windows 10 received the ConPTY API (https://devblogs.microsoft.com/commandline/windows-command-
VS Code defaults to ConPTY on Windows 10+ (from build number 18309) and falls back to winpty as a
legacy option for older versions of Windows. ConPTY can be explicitly disabled via the
! (vscode://settings/terminal.integrated.windowsEnableConpty)terminal.integrated.windowsEnableConpty
settings but this should normally be avoided.
Since ConPTY is an emulation layer, it does come with some quirks. The most common is that ConPTY
considers itself the owner of the viewport and because of that will sometimes reprint the screen. This
reprinting can cause unexpected behavior such as old content displaying after running the Terminal: Clear
command.
Remote development
This section outlines topics specific to when VS Code is connected to a remote machine using a VS Code
Remote Development (https://code.visualstudio.com/docs/remote/remote-overview) extension.
Local echo disables itself dynamically depending on the active program in the terminal. This is controlled
by
! (vscode://settings/
terminal.integrated.localEchoExcludePrograms)terminal.integrated.localEchoExcludePrograms
, which defaults to ['vim', 'vi', 'nano', 'tmux'] . It's recommended that you disable the feature for
any application or shell that is highly dynamic and/or does a lot of reprinting of the screen when typing.
{ Copy
"terminal.integrated.localEchoEnabled": false
}
Yes No
02/06/2025
Follow @code(https://go.microsoft.com/fwlink/?LinkID=533687)
Request features(https://go.microsoft.com/fwlink/?LinkID=533482)
Report issues(https://www.github.com/Microsoft/vscode/issues)
Watch videos(https://www.youtube.com/channel/UCs5Y5_7XK8HLDX0SLNwkd3w)
(https://
www.microsoft.com)
(https://go.microsoft.com/fwlink/?LinkID=533687)
(https://github.com/microsoft/vscode) (https://www.youtube.com/@code)
Support (https://support.serviceshub.microsoft.com/supportforbusiness/create?sapId=d66407ed-3967-
b000-4cfb-2c318cad363d)
Privacy (https://go.microsoft.com/fwlink/?LinkId=521839)
Terms of Use (https://www.microsoft.com/legal/terms-of-use) License (/License)