Terminal Shell Integration
Visual Studio Code has the ability to integrate with common shells, allowing the terminal to understand more about what's actually happening inside the shell. This additional information enables some useful features such as working directory detection and command detection, decorations, and navigation.
Supported shells:
- Linux/macOS: bash, fish, pwsh, zsh
- Windows: Git Bash, pwsh
Installation
Automatic script injection
By default, the shell integration script should automatically activate on supported shells launched from VS Code. This is done by injecting arguments and/or environment variables when the shell session launches. This automatic injection can be disabled by setting
terminal.integrated.shellIntegration.enabled
to false.
This standard, easy way will not work for some advanced use cases like in sub-shells, through a regular ssh session (when not using the Remote - SSH extension) or for some complex shell setups. The recommended way to enable shell integration for those is manual installation.
Note: Automatic injection may not work on old versions of the shell, for example older versions of fish do not support the
$XDG_DATA_DIRSenvironment variable which is how injection works. You may still be able to manually install to get it working.
Windows Note: VS Code shell integration requires the permission to run PowerShell scripts. If you have exclusive use of your user account on your machine, consider running:
if ((Get-ExecutionPolicy -Scope LocalMachine) -eq 'Undefined' -and (Get-ExecutionPolicy -Scope CurrentUser) -eq 'Undefined') { Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser }
Manual installation
To manually install shell integration, the VS Code shell integration script needs to run during your shell's initialization. Where and how to do this depends on the shell and OS you're using. When using manual install it's recommended to set
terminal.integrated.shellIntegration.enabled
to false, though not mandatory.
Tip: When using the Insiders build, replace
codewithcode-insidersbelow.
bash
Add the following to your ~/.bashrc file. Run code ~/.bashrc in bash to open the file in VS Code.
[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path bash)"
fish
Add the following to your config.fish. Run code $__fish_config_dir/config.fish in fish to open the file in VS Code.
string match -q "$TERM_PROGRAM" "vscode"
and . (code --locate-shell-integration-path fish)
pwsh
Add the following to your PowerShell profile. Run code $Profile in pwsh to open the file in VS Code.
if ($env:TERM_PROGRAM -eq "vscode") { . "$(code --locate-shell-integration-path pwsh)" }
zsh
Add the following to your ~/.zshrc file. Run code ~/.zshrc in zsh to open the file in VS Code.