我只想在从启动PowerShell时导入一些模块(posh git、oh my posh等) Windows Terminal
但我能看到 $profile
$profile
是否有一种方法可以识别当前正在使用的终端,以便在我的系统中执行类似操作 $profile 文件
If ($TERM -eq 'WT') { Import-Module posh-git Import-Module oh-my-posh }
您可以使用其中一个自动变量 WSLENV , WT_PROFILE_ID 或 WT_SESSION 独立的 “动力地狱。
WSLENV
WT_PROFILE_ID
WT_SESSION
function Test-IsWindowsTerminal { [bool]($env:WT_Session)}