我只想在从Windows Terminal启动 PowerShell 时导入一些模块(posh-git、oh-my-posh 等) 。当使用 conhost 或从 Cmder 启动 PowerShell 时,应排除这些导入。
但是当我从 Windows 终端或 conhost 或 Cmder 打开 PowerShell 时,我可以看到它$profile
指向同一个文件。
有没有办法可以识别当前正在使用的终端,以便我可以在我的$profile
文件中执行类似的操作?
If ($TERM -eq 'WT') {
Import-Module posh-git
Import-Module oh-my-posh
}