We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Test-WindowsTerminal.ps1
1 parent 528c4c3 commit 7f8a2f4Copy full SHA for 7f8a2f4
Test-WindowsTerminal.ps1
@@ -1,13 +1,25 @@
1
<#
2
.SYNOPSIS
3
Returns true if PowerShell is running within Windows Terminal.
4
+
5
+.FUNCTIONALITY
6
+Windows Terminal
7
8
+.LINK
9
+https://aka.ms/terminal-documentation
10
11
+.EXAMPLE
12
+Test-WindowsTerminal.ps1
13
14
+True
15
#>
16
17
#Requires -Version 7
-[CmdletBinding()] Param()
18
+[CmdletBinding()][OutputType([bool])] Param()
19
if(!$IsWindows) {return $false}
20
+if($env:WT_SESSION) {return $true}
21
for($process = Get-Process -Id $PID; $process; $process = $process.Parent)
22
{
- if($process.ProcessName -eq 'WindowsTerminal') {return $true}
23
+ if($process.ProcessName -eq 'WindowsTerminal') {return $true}
24
}
25
return $false
0 commit comments