How to Open VS Code from the Terminal and Access the Integrated Terminal
Use the code shell command to launch Visual Studio Code from any terminal, then open the integrated terminal with Ctrl+` or configure automatic panel restoration to ensure the terminal is visible on startup.
Visual Studio Code provides a robust command-line interface that allows you to open projects directly from your system terminal. While the CLI does not expose a dedicated flag to open only the integrated terminal without the editor view, you can efficiently launch the application from the shell and configure your workspace to surface the terminal immediately upon loading.
Installing the code Command in PATH
Before calling VS Code from the terminal, you must ensure the code binary is available in your system PATH. This executable serves as the entry point to the VS Code CLI and delegates arguments to the main application process.
On macOS:
Open the Command Palette (Cmd+Shift+P), type "Shell Command: Install 'code' command in PATH", and select the option to create a symlink at /usr/local/bin/code.
On Windows:
Run the VS Code installer and ensure the "Add to PATH" option is selected. The installer adds %LOCALAPPDATA%\Programs\Microsoft VS Code\bin to your environment variables.
On Linux:
The .deb, .rpm, or .tar.gz packages typically install code to /usr/bin/ or /usr/local/bin/ automatically. Verify installation by running:
code --version
Opening Files and Folders from the Terminal
Once the code command is available, invoke VS Code from any directory to open specific paths or workspace files:
# Open the current directory
code .
# Open a specific file or folder
code /path/to/project
# Open in a new window (without closing existing sessions)
code . --new-window
# Short form:
code . -n
# Reuse an existing window if one exists
code . --reuse-window
# Short form:
code . -r
The . argument represents the current working directory, allowing VS Code to open the project context immediately.
Accessing the Integrated Terminal After Launch
The VS Code CLI prioritizes file and window management over specific panel control. After launching the editor via code ., open the integrated terminal using one of these methods:
- Keyboard shortcut: Press
Ctrl+`(backtick) to toggle the terminal panel - Command Palette: Press
Ctrl+Shift+P, type "View: Toggle Terminal", and press Enter
The integrated terminal defaults to your system shell (bash, zsh, PowerShell, etc.) as configured in your settings.
Configuring Automatic Terminal Opening on Startup
To ensure the integrated terminal is visible immediately when opening VS Code from the command line, configure your user settings to restore the panel state:
- Open Settings (
Ctrl+,) - Search for "terminal" and locate "Terminal > Integrated: Default Profile" for your operating system
- Alternatively, edit
settings.jsondirectly:
{
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.defaultProfile.osx": "zsh",
"terminal.integrated.defaultProfile.linux": "bash",
"workbench.tree.indent": 20
}
While there is no native CLI flag to force the terminal open on launch, VS Code will restore the previous session’s panel state. If the terminal was visible when you last closed the window, it will reappear when you run code . again.
Summary
- Install the
codecommand via the Shell Command palette or system PATH to enable terminal invocation - Launch VS Code with
code .for the current directory orcode /path/to/folderfor specific targets - Open the integrated terminal with
Ctrl+`after launch, or rely on session restoration to maintain panel visibility - The VS Code CLI focuses on window and file management; panel visibility is controlled by internal workbench state and user settings
Frequently Asked Questions
Why does the code command not work in my terminal?
The code binary is not registered in your system PATH. On macOS, use the Command Palette to install the shell command. On Windows, reinstall VS Code and ensure the "Add to PATH" checkbox is selected. On Linux, verify the binary exists in /usr/bin/code or create a manual symlink.
Can I open VS Code from the terminal with the integrated terminal already maximized?
There is no command-line flag to maximize only the terminal panel. However, VS Code restores your previous workspace state. Toggle the terminal to your preferred size before closing the window; it will reopen in that state when you next launch with code ..
How do I change the default shell for the VS Code integrated terminal?
Set the terminal.integrated.defaultProfile.{platform} setting in your settings.json file. Valid options include bash, zsh, fish, PowerShell, CommandPrompt, or custom profiles defined in your configuration.
Does opening VS Code from the terminal affect environment variables?
Yes. When launching via code ., VS Code inherits environment variables from the parent shell process. This is crucial for tools like virtualenv, nvm, or custom PATH modifications made in your shell profile, as they will be available in the integrated terminal.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s https://instagit.com/install.md