You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何去除VS Code终端中多余的文本内容?

VS Code终端多余文本及路径隐藏解决方案

针对终端前缀路径和启动提示的处理

PowerShell用户

  1. 打开PowerShell配置文件:在终端输入 notepad $PROFILE,若提示文件不存在直接创建。
  2. 替换为以下代码,仅显示当前文件夹名作为提示符,禁用启动欢迎信息:
function prompt {
    $currentDir = Split-Path -leaf (Get-Location)
    Write-Host "$currentDir> " -NoNewline -ForegroundColor Cyan
    return " "
}
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
$env:POSH_DISABLE_SMART_TITLE = $true

CMD用户

  1. 点击VS Code左下角终端的下拉菜单,选择「选择默认配置文件」,设置CMD为默认。
  2. 打开settings.json(快捷键Ctrl+, → 右上角JSON图标),添加:
"terminal.integrated.profiles.windows": {
    "Command Prompt": {
        "path": ["${env:windir}\\System32\\cmd.exe"],
        "args": ["/k", "prompt $g "]
    }
},
"terminal.integrated.defaultProfile.windows": "Command Prompt"

/k prompt $g 会将CMD提示符简化为>,完全隐藏路径。

针对代码运行时的多余输出

如果使用「运行和调试」面板执行代码,修改launch.json:

  1. 打开「运行和调试」面板,点击「创建launch.json文件」,选择对应语言(以Python为例)。
  2. 配置如下,关闭命令回显和多余提示:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: 当前文件",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen",
            "env": {"PYTHONUNBUFFERED": "1"}
        }
    ]
}

Python用户额外添加到settings.json:

"python.terminal.executeInFileDir": false,
"python.terminal.launchArgs": ["-u"]

通用禁用终端冗余提示

在settings.json中添加以下配置,关闭shell集成提示、退出警告等:

"terminal.integrated.shellIntegration.enabled": false,
"terminal.integrated.showExitAlert": false,
"terminal.integrated.enablePersistentSessions": false

内容的提问来源于stack exchange,提问作者Hodinit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 10:20:25