powershell - 我可以在 Powershell 中检测到我正在 VS Code 的集成终端中运行吗?

标签 powershell visual-studio-code

如果 Powershell 在 VS Code 集成终端内打开,我想修改 Windows 中的标准 PowerShell 配置文件(当您在 VS Code 中编辑例如 python 脚本时,而不是 PS 脚本,在任何情况下都会打开 ISE 配置文件)。

是否有一些由集成 PowerShell 设置的环境变量?或者是否有某种方法可以使用特定配置文件而不是默认配置文件打开 Powershell?

谢谢

最佳答案

VS Code 创建一个名为 TERM_PROGRAM 的环境变量.您可以检查它的值 vscode ,像这样:

if($env:TERM_PROGRAM -eq 'vscode') {
  # do some stuff...
}

关于powershell - 我可以在 Powershell 中检测到我正在 VS Code 的集成终端中运行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57788150/

相关文章:

string - Powershell 参数列表和双+ 空格

search - 为什么在 Visual Studio Code OSX 中的文件中查找会忽略我的 search.excludeFolders 设置?

python - 如何解决意外的 token 解析器 16 Visual Studio 代码

node.js - 在 vs 代码中调试在 typescript Node 中编写的 jasmine 测试

android - 调试控制台 : Error: ADB exited with exit code 1 Performing Streamed Install. .. F

parsing - Powershell 解析文本文件的一部分并保存到 CSV

powershell - 在资源管理器中对选定文件执行 PowerShell 命令

python - 比较 PowerShell 和 Python 生成的 Windows PowerShell 中的两个 JSON 对象

typescript - 在 Visual Studio Code 中显示未使用的 Typescript 变量

powershell - 在 PowerShell New-Item 命令的路径中使用驱动器盘符