This guide shows you how to select which shell (like PowerShell, Command Prompt, or Bash) VS Code uses for its integrated terminal, and how to run commands inside it. You’ll learn how to switch shells per workspace, change the default, and execute commands efficiently. No prior terminal experience is needed, but basic familiarity with VS Code’s interface helps.
What You’ll Need
- Visual Studio Code installed (any recent version).
- At least one shell available on your system: Windows has PowerShell and Command Prompt; macOS and Linux come with Bash (and often Zsh).
- Optional: Git Bash, WSL, or other shells you may have installed.
Step-by-Step
- Open the Integrated Terminal: In VS Code, press
Ctrl+`(backtick) on Windows/Linux orCmd+`on macOS. Alternatively, go to the menu View → Terminal. This opens a terminal panel at the bottom of the window. - See the Current Shell: The terminal opens with your default shell. Look at the right side of the terminal panel’s title bar—you’ll see the shell name (e.g., “powershell”, “bash”, “cmd”).
- Choose a Different Shell for This Session: Click the dropdown arrow next to the + icon in the terminal panel’s top-right corner. A list of available shells appears. Click any shell to open a new terminal tab with that shell. This does not change your default—it’s just for this session.
- Change the Default Shell (Windows): Open the Command Palette with
Ctrl+Shift+P(orCmd+Shift+Pon macOS). Type Terminal: Select Default Profile and press Enter. A list of detected shells appears. Select the one you want as the default. The next time you open a terminal, it will use this shell. - Change the Default Shell (macOS/Linux): The same steps work: Command Palette → Terminal: Select Default Profile. If your shell isn’t listed, you may need to add it manually (see Tips).
- Run a Command: Type a command in the terminal and press Enter. For example, type
echo helloand press Enter—you’ll see “hello” printed. Commands are executed in the current directory (shown at the prompt). - Run a Command in a Specific Shell: If you want to run a command in a different shell without opening a new tab, you can use the shell’s syntax directly. For instance, in PowerShell, you can run
bash -c "ls"to execute a Bash command. But it’s usually cleaner to open a new tab with the desired shell. - Kill or Restart the Terminal: To stop a running command, press
Ctrl+C(orCmd+Con macOS). To restart the terminal (e.g., after changing settings), click the trash can icon in the terminal panel’s top-right corner, then open a new terminal.
Common Mistakes
- Using the wrong command syntax: Each shell has its own syntax. For example,
lsworks in Bash and PowerShell (as an alias), butdiris for Command Prompt. If a command fails, check which shell you’re in. - Forgetting to save settings: When you change the default profile, the change takes effect immediately for new terminals, but if you have an existing terminal open, it won’t switch. Close and reopen the terminal to see the change.
- Selecting a shell that isn’t installed: The list of profiles only shows shells VS Code detects. If you pick one that’s broken, the terminal may fail to open. Always test a shell before making it default.
- Running GUI commands in the terminal: Some commands open graphical applications (like
code .opens VS Code). They may block the terminal until closed. Use&(in Bash) orStart-Process(in PowerShell) to run them in the background.
Tips
- Add a custom shell: If your shell isn’t listed, you can add it manually. Open File → Preferences → Settings (or
Ctrl+,), search forterminal.integrated.profiles.windows(or.linux/.osx), and edit the JSON to include the path to your shell executable. - Use keyboard shortcuts:
Ctrl+Shift+`opens a new terminal with the default profile.Ctrl+Shift+5splits the terminal.Ctrl+PageUp/PageDownswitches between terminal tabs. - Set a default for a workspace: You can create a
.vscode/settings.jsonfile in your project folder and add"terminal.integrated.defaultProfile.windows": "bash"(adjust for your OS) to force a specific shell for that project. - Check the shell’s environment: When you switch shells, the environment variables (like PATH) may differ. If a command isn’t found, it might be because the shell doesn’t have the right PATH. Use
echo $PATH(Bash) or$env:PATH(PowerShell) to inspect. - Use the terminal’s dropdown to see all open shells: The dropdown next to the + icon also shows all active terminal tabs; you can jump between them quickly.
Troubleshooting
- Terminal doesn’t open or shows an error: This often means the selected shell isn’t found. Go to Terminal: Select Default Profile and choose a known-good shell like PowerShell or Bash. If that fails, check your VS Code installation—you may need to reinstall or update.
- Command not recognized: The command may be a shell built-in or in a different PATH. Try using the full path (e.g.,
/usr/bin/python). Also, ensure you’re in the correct shell—dirwon’t work in Bash. - PowerShell execution policy blocks scripts: On Windows, you might see an error about running scripts. You can change the policy with
Set-ExecutionPolicy RemoteSigned -Scope CurrentUserin an administrator PowerShell, but be cautious—this affects security. - Shell opens but is slow or unresponsive: This can be due to a slow startup script (like a large
.bashrc). Try opening a different shell to see if the issue persists. You can also disable shell integration in VS Code settings:terminal.integrated.shellIntegration.enabledto false. - Changes to default profile don’t stick: Ensure you’re selecting the profile from the Command Palette, not just opening a new terminal. Also, check if your workspace has a
settings.jsonthat overrides the default.
Frequently Asked Questions
How do I change the default shell in VS Code?
Open the Command Palette (Ctrl+Shift+P), type Terminal: Select Default Profile, and choose your preferred shell. New terminals will use it.
Can I use a different shell for each project?
Yes. Create a .vscode/settings.json in your project folder and add a line like "terminal.integrated.defaultProfile.windows": "bash" (adjust for your OS). This overrides the global default for that workspace.
Why does my terminal show a different shell than the one I selected?
If you have multiple terminal tabs open, each may have a different shell. Check the tab title or the dropdown. Also, if you changed the default, existing terminals won’t change—open a new one.
How do I run a command as administrator in VS Code terminal?
In Windows, you can run Start-Process powershell -Verb RunAs to open an elevated PowerShell window. In macOS/Linux, use sudo before the command, but be careful—it requires your password and can be risky.
Can I set environment variables for the terminal?
Yes, you can set them in your shell’s startup file (like .bashrc or .zshrc) or use the terminal.integrated.env.windows setting in VS Code to add variables for all terminals.
Why is the terminal not showing colors or formatting?
This may be due to the shell’s color scheme or VS Code’s theme. Try setting terminal.integrated.allowChords to false if keyboard shortcuts interfere. Also, ensure your shell supports ANSI colors (most do).
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Valheim Server Not Showing in Community List Fixes
- DisplayPort vs HDMI: Which Cable Should You Use?
- Soundbar vs 2.1 Speaker System: Which Is Better?
- Survive Lava for Brainrot Tier List170 points
- MySQL Dump Import: Fix Common Errors
- Mouse Moving on Its Own? Causes & Fixes