iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

Integrated Terminal

VS Code’s integrated terminal puts a shell next to the editor. Multiple terminals, split panes, profiles per shell, search through scroll-back, paste from clipboard — same shell you’d use externally, but stitched into the editor.

Profiles, shortcuts, tasks, integration

EXAMPLE
// 1) Open / close / focus
// Ctrl + `         — toggle terminal
// Ctrl + Shift + `  — new terminal (alongside existing)
// Ctrl + Shift + 5  — split current terminal
// Ctrl + Shift + Q  — focus next terminal
// Ctrl + W in terminal — close it

// 2) Profiles — pick a default shell per OS
// settings.json
{
    "terminal.integrated.defaultProfile.windows": "PowerShell",
    "terminal.integrated.defaultProfile.osx":     "zsh",
    "terminal.integrated.defaultProfile.linux":   "bash",

    "terminal.integrated.profiles.windows": {
        "PowerShell":   { "path": "powershell.exe", "icon": "terminal-powershell" },
        "Command Prompt": { "path": "cmd.exe" },
        "Git Bash":     { "source": "Git Bash" },
        "WSL":          { "path": "wsl.exe" }
    },
    "terminal.integrated.profiles.osx": {
        "zsh":  { "path": "zsh", "args": ["-l"] },
        "bash": { "path": "bash" },
        "fish": { "path": "/opt/homebrew/bin/fish" }
    }
}

// 3) Pick a profile on demand
// Terminal panel dropdown → 'Select Default Profile' → 'Launch Profile…'

// 4) Working directory
{
    "terminal.integrated.cwd": "${workspaceFolder}",
    "terminal.integrated.splitCwd": "workspaceRoot"     // 'inherited' | 'workspaceRoot' | 'initial'
}

// 5) Useful keyboard shortcuts (most platforms)
// Ctrl + L           — clear screen (or Cmd + K on macOS)
// Ctrl + R           — reverse search through history (bash/zsh)
// Ctrl + C           — send SIGINT (cancel current command)
// Ctrl + D           — exit shell / EOF
// Ctrl + U           — clear current line
// Ctrl + W           — delete previous word
// Ctrl + ←/→         — move by word
// Up/Down            — history navigation
// Ctrl + Shift + F   — search terminal scroll-back
// Ctrl + Shift + Up  — jump to previous command (uses shell integration)

// 6) Shell integration — the killer feature
// Detects command boundaries, lets you:
//   - Ctrl + Up/Down to jump between commands
//   - Hover a previous command to see exit code + duration
//   - Rerun a command with one click
//   - 'Open detected link' on file paths in output
// Enable: terminal.integrated.shellIntegration.enabled (default on)
// Manual install (if not detected): terminal → 'Install Shell Integration'

// 7) Hyperlink-clickable paths in output
// stack traces, test failures, file references — Ctrl/Cmd + click to open
// Customise with terminal.integrated.enableFileLinks setting.

// 8) Multiple terminals + tabs
// Each terminal has a tab; rename with right-click → Rename
// Pin tab; change icon; assign a color (helps distinguish dev / test / build)

// 9) Run a task instead of typing the command
// .vscode/tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label":    "npm: dev",
            "type":     "npm",
            "script":   "dev",
            "isBackground": true,
            "problemMatcher": ["$tsc-watch", "$eslint-stylish"],
            "group": { "kind": "build", "isDefault": true },
            "presentation": {
                "reveal": "always",
                "panel":  "dedicated",
                "clear":  true
            }
        }
    ]
}
// Ctrl + Shift + B → run default build task
// Ctrl + Shift + P → 'Tasks: Run Task' → pick

// 10) Problem matchers — surface compile/lint errors in Problems panel
// TS, ESLint, Stylelint, Cargo, Go, Python all have built-in matchers.
// In a task: "problemMatcher": ["$tsc", "$eslint-stylish"]

// 11) Run from a keybinding
// keybindings.json
[
    {
        "key":     "ctrl+shift+t",
        "command": "workbench.action.tasks.runTask",
        "args":    "npm: test"
    }
]

// 12) Terminal links (custom regex)
{
    "terminal.integrated.commandsToSkipShell": [
        "workbench.action.toggleSidebarVisibility"
    ]
}

// 13) Copy / paste behavior (some shells eat Ctrl+C)
{
    "terminal.integrated.copyOnSelection": true,
    "terminal.integrated.rightClickBehavior": "copyPaste",
    "terminal.integrated.cursorBlinking":      true,
    "terminal.integrated.cursorStyle":         "line"
}

// 14) Font + colors
{
    "terminal.integrated.fontFamily":    "JetBrains Mono, Menlo, monospace",
    "terminal.integrated.fontSize":      14,
    "terminal.integrated.lineHeight":    1.1,
    "workbench.colorCustomizations": {
        "terminal.background": "#0b0b0b",
        "terminal.foreground": "#eaeaea"
    }
}

// 15) Remote development
// VS Code Remote-SSH / Dev Containers — the integrated terminal runs INSIDE the remote.
// Native feel for SSH boxes, containers, WSL.

// 16) Common workflows
//   • Open a terminal next to the file you're editing (split view) — copy + paste paths quickly
//   • Multiple terminals: dev server, test watch, git, scratch
//   • Pin and color-code: dev (green), test (orange), build (red)
//   • Use the Problems panel to see lint / TS errors from a watch task
//   • Use 'Run Task' instead of typing the same npm script

// 17) Tips for productivity
//   • Customise the prompt (Starship, oh-my-zsh, oh-my-posh) — it shows in the integrated terminal
//   • Add your shell aliases — VS Code respects ~/.zshrc / ~/.bashrc / $PROFILE
//   • Mark commands you want bookmarked: terminal scrollback search + 'Show Detected Links'
//   • Use terminal in conjunction with tasks; not everything needs to be a task
//   • Don't use terminal for things VS Code has a UI for (git, debugging) — both have their lane

// 18) Anti-patterns
//   ❌ Running long-lived servers in interactive terminals when you could use a task → terminal stays useful for ad-hoc commands
//   ❌ Pasting secrets into the terminal — they live in shell history
//   ❌ Mixing shells in one workspace without naming them → confusing
//   ❌ Disabling shell integration — you lose 'Ctrl + Up to jump to previous command'

Why it matters

Shell integration (Ctrl + Up to jump between commands, click file paths to open) is the killer feature. Pair with named + color-coded terminals for dev / test / build — productivity per pixel goes way up.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
// Toggle:   Ctrl + `   (backtick)
// Split:    Ctrl + Shift + 5
// New tab:  Ctrl + Shift + `
// Pick your shell via settings.json: "terminal.integrated.defaultProfile.windows": "PowerShell"
Try it Yourself »

Exercise

Toggle the integrated terminal.

Ctrl +

Discussion

Loading…