VSCode 突然默认为集成终端和任务的 powershell [英] VSCode is suddenly defaulting to powershell for integrated terminal and tasks

查看:39
本文介绍了VSCode 突然默认为集成终端和任务的 powershell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我今天早上醒来并启动 VSCode 时,我的默认终端在启动时,现在运行任务时是 powershell,而不是 Git Bash.我在窗户上.我曾尝试更改 settings.json 无济于事.有什么我遗漏的吗?

<代码>{workbench.startupEditor":newUntitledFile",terminal.integrated.shell.windows":C:\\Program Files\\Git\\bin\\bash.exe",[javascript]":{editor.defaultFormatter":rvest.vs-code-prettier-eslint"},aws.samcli.location":C:\\Users\\king\\AppData\\Roaming\\npm\\sam.exe",typescript.updateImportsOnFileMove.enabled":总是",[html]":{editor.defaultFormatter":vscode.html-language-features"},editor.formatOnSave":真,editor.formatOnPaste":真,javascript.updateImportsOnFileMove.enabled":总是",explorer.confirmDragAndDrop":假,diffEditor.maxComputationTime":0,extensions.ignoreRecommendations":真,[打字稿]":{editor.defaultFormatter":esbenp.prettier-vscode"},editor.renderControlCharacters":真,[jsonc]":{editor.quickSuggestions":{字符串":真},editor.suggest.insertMode":替换"},window.zoomLevel":0,editor.accessibilitySupport":关闭",workbench.editor.untitled.hint":隐藏",terminal.integrated.defaultProfile.windows":Git Bash",terminal.external.windowsExec":C:\\Program Files\\Git\\bin\\bash.exe",terminal.explorerKind":外部",terminal.integrated.automationShell.linux":"}

我发现了这个 进行设置:

  • 注意:即使您的 settings.json 包含 no(适合平台)terminal.integrated.profiles.*" 设置,Visual Studio 代码具有它知道的内置 标准 配置文件,并在选择 默认 shell 时提供它们供选择.

    • 这些标准配置文件混合了主机平台附带的 shell 以及 Visual Studio 在给定系统上动态检测的一些 shell,例如 Windows 上的 Git Bash.
  • 创建标准配置文件显式,请执行以下操作:

    • 注意:您可以选择这样做以自定义标准配置文件.但是,如果您的意图仅仅是添加自定义配置文件 - 请参阅此答案以获取示例 -没有必要在 "terminal.integrated.profiles.*" 设置中创建标准配置文件,因为即使没有明确定义,Visual Studio Code 也知道它们.

    • 通过<代码>文件>首选项设置(Ctrl-,),搜索profiles,然后点击相应平台下面的Edit in settings.json>终端>集成>配置文件 >* 设置;这将打开 settings.json 进行编辑,并添加标准配置文件;只需保存文件就足够了.

      • 注意:如果显示的 terminal.integrated.profiles.*" 设置不包含预期的、适合平台的标准配置文件,则该名称的设置可能已经存在;强制创建标准配置文件,删除或注释掉现有设置并保存文件,然后重试.
    • 在 Windows 上,您将得到如下结果:

      terminal.integrated.profiles.windows":{PowerShell":{来源":PowerShell",图标":终端-powershell"},命令提示符":{路径":[${env:windir}\\Sysnative\\cmd.exe",${env:windir}\\System32\\cmd.exe"],参数":[],图标":终端-cmd"},Git Bash":{来源":Git Bash"}}

您在问题中链接的答案提供了Visual Studio Code 中使用的各种类型的外壳的概述,已更新以反映有关新外壳配置文件的信息.>


[1] 注意:如果找到 PowerShell (Core) v6+ 安装,它优先于内置的 Windows PowerShell 版本.上>

When I woke up this morning and launched VSCode my default terminal on launch, and when running tasks is now powershell, instead of Git Bash. I am on windows. I have tried changing the settings.json to no avail. Is there something I'm missing?

{
    "workbench.startupEditor": "newUntitledFile",
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "[javascript]": {
        "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
    },
    "aws.samcli.location": "C:\\Users\\king\\AppData\\Roaming\\npm\\sam.exe",
    "typescript.updateImportsOnFileMove.enabled": "always",
    "[html]": {
        "editor.defaultFormatter": "vscode.html-language-features"
    },
    "editor.formatOnSave": true,
    "editor.formatOnPaste": true,
    "javascript.updateImportsOnFileMove.enabled": "always",
    "explorer.confirmDragAndDrop": false,
    "diffEditor.maxComputationTime": 0,
    "extensions.ignoreRecommendations": true,
    "[typescript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "editor.renderControlCharacters": true,
    "[jsonc]": {
    
        "editor.quickSuggestions": {
            "strings": true
        },
        "editor.suggest.insertMode": "replace"
    },
    "window.zoomLevel": 0,
    "editor.accessibilitySupport": "off",
    "workbench.editor.untitled.hint": "hidden",
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "terminal.external.windowsExec": "C:\\Program Files\\Git\\bin\\bash.exe",
    "terminal.explorerKind": "external",
    "terminal.integrated.automationShell.linux": ""
}

I found this related SO post making the default powershell, but I didn't see anything that was incorrect about my setting...especially because my goal is the opposite- to stop Powershell!

解决方案

Update: Version v1.60.0 had a bug. Upgrade to v1.60.1 or higher for a fix.

The bug manifested in the following symptoms:

  • The Open in Integrated Terminal shortcut-menu command in the Explorer pane's shortcut always uses the built-in default shell (PowerShell on Windows), ignoring the configured one.

  • The same goes for running tasks (with or without a separate terminal.integrated.automationShell.* setting).

  • Also, if a given folder or workspace happened to have an integrated terminal open when quitting Visual Studio Code, the shell that is launched when the integrated terminal automatically reopens the next time is again the built-in default shell, not the configured one. By contrast, if reopening doesn't auto-open the integrated terminal, opening it manually does respect the configured default shell, and so does manually creating another shell instance later.

See GitHub issue #132150

The following information turned out to be unrelated to the bug, but is hopefully still useful general information about Visual Studio Code's recent change in how shells for the integrated terminal are configured:


Migrating from the legacy default shell settings to shell profiles:

  • Recently, the "terminal.integrated.shell.*" and "terminal.integrated.shellArgs.*" settings were deprecated and replaced with a more flexible model that allows defining multiple shells to select from, via so-called shell profiles, optionally defined in setting "terminal.integrated.profiles.*", with an associated mandatory "terminal.integrated.defaultProfile.*" setting referencing the name of the profile to use by default - which may be an explicitly defined custom profile or one of the built-in, platform-appropriate default profiles.

    • Note: * in the setting names above represents the appropriate platform identifier, namely windows, linux, or osx (macOS).
  • As of v1.60.1, if legacy "terminal.integrated.shell.*" settings are also present, the new settings take precedence (even though the tooltip when editing "terminal.integrated.shell.*" in settings.json suggests that this change is yet to come).

    • In the absence of both settings, Visual Studio Code's built-in default shell is used, which on Windows is PowerShell,[1] and on Unix-like platforms the user's default shell, as specified in the SHELL environment variable.

    • Recent Visual Studio Code versions, starting before v1.60 - seemingly as one-time opportunity - displayed a prompt offering to migrate the deprecated settings to the new ones.

      • Accepting the migration results in the following:

        • Creation of setting "terminal.integrated.shell.*" containing a custom shell profile derived from the values of legacy settings "terminal.integrated.shell.*" and, if present, "terminal.integrated.shellArgs.*"; that custom profile's name has the suffix (migrated)
        • Creation of setting terminal.integrated.defaultProfile.* whose value is the migrated profile's name, making it the default shell.
        • Removal of legacy settings "terminal.integrated.shell.*" and "terminal.integrated.shellArgs.*"
      • If you decline the migration, you can later effectively perform it by re-choosing the default shell, as described below.

        • Note: The new "terminal.integrated.defaultProfile.*" setting that is created in the process then effectively overrides the legacy "terminal.integrated.shell.*" and "terminal.integrated.shellArgs.*" settings, but the latter won't be removed automatically. To avoid confusion, it's best to remove them from settings.json manually.
  • Choose the default shell profile to use in order to (re)specify the default shell:

    • Click on the down-arrow part of the shell-selector icon () on the right side of the integrated terminal, select Select Default Profile, which presents a list of the defined profiles to select the default from - in the absence of explicitly defined profiles, standard profiles are offered (see below).

    • This translates into a terminal.integrated.defaultProfile.* setting in settings.json, whose value is the name of the chosen shell profile - which may be the name of a built-in profile or one of the ones explicitly defined in "terminal.integrated.profiles.*"

    • Note: This shell is by default also used for tasks (defined in tasks.json), but that can be overridden with a "terminal.integrated.automationShell.*" setting pointing to the executable of an alternative shell.

  • Optionally, in your settings.json file, you may create a platform-appropriate terminal.integrated.profiles.* setting with shell profiles of interest:

    • Note: Even if your settings.json contains no (platform-appropriate) "terminal.integrated.profiles.*" setting, Visual Studio code has built-in standard profiles it knows of and offers them for selection when choosing the default shell.

      • These standard profiles are a mix of shells that come with the host platform as well as some that Visual Studio detects dynamically on a given system, such as Git Bash on Windows.
    • To create the standard profiles explicitly, do the following:

      • Note: You may choose to do this in order to customize the standard profiles. However, if your intent is merely to add custom profiles - see this answer for an example - it isn't necessary to create the standard profiles inside the "terminal.integrated.profiles.*" setting, because Visual Studio Code knows about them even if not explicitly defined.

      • Via File > Preferences > Settings (Ctrl-,), search for profiles and click on Edit in settings.json below the platform-appropriate Terminal > Integrated > Profiles > * setting; this will open settings.json for editing, with the standard profiles added; simply saving the file is sufficient.

        • Note: If the "terminal.integrated.profiles.*" setting shown doesn't contain the expected, platform-appropriate standard profiles, a setting by that name may already be present; to force creation of the standard profiles, remove or comment out the existing setting and save the file, then try again.
      • On Windows, you'll end up with something like the following:

        "terminal.integrated.profiles.windows": {
          "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell"
          },
          "Command Prompt": {
            "path": [
              "${env:windir}\\Sysnative\\cmd.exe",
              "${env:windir}\\System32\\cmd.exe"
            ],
            "args": [],
            "icon": "terminal-cmd"
          },
          "Git Bash": {
            "source": "Git Bash"
          }
        }
        

The answer you link to in your question, which provides an overview of the various types of shells used in Visual Studio Code, has been updated to reflect the information about the new shell profiles.


[1] Note: If a PowerShell (Core) v6+ installation is found, it takes precedence over the built-in Windows PowerShell version.

这篇关于VSCode 突然默认为集成终端和任务的 powershell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆