{
// ...
// **General-purpose integrated-terminal shell**.
// Shell *profiles* define the *available* shells for the integrated terminal.
// This property is situationally created automatically, platform-appropriately,
// based on what shells VSCode finds in standard locations on your
// system.
// However, it *need not be present* in a given file - VSCode
// knows about about *standard* profiles *implicitly* when it
// comes to choosing a default shell.
// This example applies to Windows, and shows that Git Bash
// was found on the system.
// On Unix-like platforms, replace ".windows" with ".osx" or ".linux",
// as appropriate.
// To add custom profiles:
// * In file *paths*, use "\\" or "/" as the path separator.
// * Use an "args" array property to specify start-up arguments, if necessary.
"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"
}
}
// Define the *default* shell profile, which serves as the default
// shell in the *integrated terminal* and - except
// if overridden, as shown below - also for *tasks*.
"terminal.integrated.defaultProfile.windows": "PowerShell"
// **Automation-tasks shell**,
// for the tasks defined in "tasks.json" and for debugging:
// This definition is *optional* and *overrides* the default shell configured above.
// Note:
// * The *executable file path* must be specified (just the file name is sufficient for executables present in %PATH%);
// that is, this setting doesn't reference the shell *profiles*.
// * There is NO way to pass startup arguments.
"terminal.integrated.automationShell.windows": "cmd.exe",
// **External-terminal executable**:
// The *terminal program* to use for opening an external terminal window, which itself determines what shell to launch.
// (> Open New External Terminal).
// Note:
// * The *executable file path* must be specified (just the file name is sufficient for executables present in %PATH%);
// * There is NO way to pass startup arguments.
// * This example specifies Windows Terminal (wt.exe).
// * On Windows only, you may also specify a *shell* executable directly,
// which then opens in a regular console window (conhost.exe)
"terminal.external.windowsExec": "wt.exe",
// **PowerShell Integrated Console**:
// Profile loading is *disabled* by default; you can enable it here, but
// note that the PowerShell Integrated Console has its own,
// separate $PROFILE location, which differs from the one in a
// regular console window. If you want to load your regular profile,
// place the following statement in the $PROFILE file of
// the Integrated Console:
// . ($PROFILE -replace '\.VSCode', '.PowerShell')
// (Open the profile file for editing by submitting the following command
// from the Integrated Console:
// code $PROFILE
// )
"powershell.enableProfileLoading": false,
// ...
}
如果未显示感兴趣的版本,您必须通过Settings GUI(从PowerShell会话菜单中选择Modify list of additional PowerShell locations)或通过settings.json文件(参见下一节)添加其可执行路径。 通过x1米30纳米1 x(x1米31纳米1 x):
{
// ...
// The paths to any PowerShell executables that the extension cannot auto-discover.
// The property names are self-chosen names, which show in the
// PowerShell session menu.
// Note:
// * Executable paths only are supported, not also arguments.
// * If a value isn't a valid executable path, it is ignored,
// and the version doesn't show up in the session menu.
// In the status bar, the currently active version is displayed by its actual characteristics,
// not by these self-chosen property names; e.g.,
// "PowerShell 7.2")
"powershell.powerShellAdditionalExePaths": {
"Latest Preview": "C:\\Users\\jdoe\\AppData\\Local\\Microsoft\\powershell\\pwsh.exe"
},
// The PowerShell version to use by default, which can be
// a property name from "powershell.powerShellAdditionalExePaths" or
// the name of an auto-discovered version, as show in the PowerShell
// session menu.
"powershell.powerShellDefaultVersion": "Latest Preview",
// ...
}
2条答案
按热度按时间w1jd8yoj1#
PowerShell扩展的
PowerShell: Enable Profile Loading
选项 * 未选中 *(通过File > Preferences > Settings
、Ctrl-、)。"args"
参数值为[ "-noprofile" ]
,方法是直接编辑设置settings.json
(命令面板中的>Preferences: Open Settings (JSON)
)的JSON文件。settings.json
摘录,其中包含一个修改后的默认PowerShell配置文件,该配置文件抑制了配置文件加载。请继续阅读,了解有关Visual Studio代码中 shell 和终端的详细常规信息。
Visual Studio代码中的shell和终端设置概述:
3种不同类型的 shell 适用:
**集成端子的默认 shell (面板的
TERMINAL
选项卡)。tasks.json
中定义),而不是默认的集成终端shell。> Open New External Terminal
);注意,在Windows上你可以 * 直接 * 指定一个shell可执行文件,但是在类Unix平台上你必须指定一个 * 终端应用程序 *,它 * 自己 * 决定要启动的shell-参见下面的详细信息。这些壳体:
-NoProfile
。****默认 * shell**为:
SHELL
**环境变量中。conhost.exe
,用于启动cmd.exe
(命令提示符)Terminal.app
,它 * 本身 * 决定启动哪个shell(尽管默认情况下,它也是用户的默认shell)。bash.exe
),在这种情况下,它将在常规控制台窗口(conhost.exe
)中打开以下摘录自
Settings.json
文件(> Preferences: Open Settings (JSON)
),显示了每种配置的相关设置(自VSCode v1.60 / PowerShell扩展v2021.8.2起):"terminal.integrated.shell.*"
和"terminal.integrated.shellArgs.*"
设置确定了集成终端的默认shell及其启动参数。这些设置已被shell profiles(通过"terminal.integrated.profiles.*"
属性定义)和关联的"terminal.integrated.defaultProfile.*"
属性(包含要使用的配置文件的 name)所取代,如下所示。*如果要配置PIC(PowerShell集成控制台 )以使用 * 不同的PowerShell版本:
注意:从PowerShell扩展的
v2022.6.3
版本开始编写。GUI方法:
{}
,然后在弹出的工具提示窗口中单击Show PowerShell Session Menu
,如下图所示。PowerShell: Show Session Menu
以打开相关菜单。)
)
这将在命令调色板中打开PowerShell会话菜单:从其他可用版本(如果有的话)中选择前缀为
Switch to:
的版本,这 * 使该版本成为以后的默认版本 *。如果未显示感兴趣的版本,您必须通过Settings GUI(从PowerShell会话菜单中选择
Modify list of additional PowerShell locations
)或通过settings.json
文件(参见下一节)添加其可执行路径。通过x1米30纳米1 x(x1米31纳米1 x):
powershell.powerShellAdditionalExePaths
设置是一个 * 单个对象 *,允许您添加扩展无法通过 * 自选属性名称 * 自动找到的PowerShell版本的完整可执行路径-请参见下面的示例。powershell.powerShellDefaultVersion
属性确定要使用的版本 * 默认情况下 * 是powershell.powerShellAdditionalExePaths
设置的属性名称或自动发现的版本的名称,如会话菜单中所示。从菜单中选择Switch to:
条目会自动更新此设置。j8ag8udp2#
您可以进入powershell扩展设置并删除“PowerShell:启用配置文件加载”,我认为它的帮助。还检查任务运行powershell脚本与一些参数discussion about task