visual-studio - 删除 Visual Studio 终端中的 "Visual Studio 2022 Developer PowerShell" header

标签 visual-studio powershell

每当我在 Visual Studio 中打开终端时,我都会收到以下样板 header :

**********************************************************************
** Visual Studio 2022 Developer PowerShell v17.5.1
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************

Visual Studio 2022 Developer PowerShell

查看选项 > 环境 > 终端中的终端设置,我使用以下 shell 位置:

C:\Program Files\PowerShell\7\pwsh.exe

连同以下参数:

-NoExit -Command "& { Import-Module """$env:VSAPPIDDIR\..\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell -SkipAutomaticLocation -SetDefaultWindowTitle -InstallPath $env:VSAPPIDDIR\..\..\}"

通常,您可以通过添加 -NoLogo 来删除 powershell 标题文本。标记“在启动时隐藏版权横幅。”,但这似乎在这里没有效果。

我认为这是从 Enter-VsDevShell 生成的部分。

这特别烦人的原因是我通常将终端固定在底部且高度最小,因此对视觉空间的要求非常高。

有什么方法可以删除这里的启动文本吗?

最佳答案

  • 添加redirection *>$null 使 Enter-VsDevShell

    的所有输出静音
  • 一般情况下,使用 \" 转义嵌入的 " 字符。 (适用于 powershell.exe (Windows PowerShell) 和 pwsh.exe (PowerShell (Core) 7+)。

    • 在这种特殊情况下,不需要嵌入引号,因为路径以(环境)变量引用开头,后面是不需要引号的文字子路径。
  • 删除 & { ... } 中不必要的封装 - 只需 ... 即可。

-NoExit -Command "Import-Module $env:VSAPPIDDIR\..\Tools\Microsoft.VisualStudio.DevShell.dll; Enter-VsDevShell -SkipAutomaticLocation -SetDefaultWindowTitle -InstallPath $env:VSAPPIDDIR\..\..\ *>$null"

关于visual-studio - 删除 Visual Studio 终端中的 "Visual Studio 2022 Developer PowerShell" header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75608065/

相关文章:

c# - 是否可以以编程方式创建哈希规则?

visual-studio - 如果文件夹不存在,MSBuild 创建文件夹

c# - 使用VS14构建Monodevelop时出错

javascript - Visual Studio/ASP.NET MVC 项目上的 JSLint

visual-studio - 为什么我在 unit3d 上而不是在 Visual Studio 上出现此错误

powershell - 收集远程计算机上的登录用户名?

powershell - 找不到接受参数 'Files\'的位置参数

powershell - 如何将一个脚本中的未绑定(bind)参数作为参数传递给另一个脚本?

arrays - powershell比较运算符包含与大数组