Skip to content

Commit 7f8a2f4

Browse files
committed
⚡️ Improve Test-WindowsTerminal.ps1
- resolves brianary#99
1 parent 528c4c3 commit 7f8a2f4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Test-WindowsTerminal.ps1

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
<#
22
.SYNOPSIS
33
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
415
#>
516

617
#Requires -Version 7
7-
[CmdletBinding()] Param()
18+
[CmdletBinding()][OutputType([bool])] Param()
819
if(!$IsWindows) {return $false}
20+
if($env:WT_SESSION) {return $true}
921
for($process = Get-Process -Id $PID; $process; $process = $process.Parent)
1022
{
11-
if($process.ProcessName -eq 'WindowsTerminal') {return $true}
23+
if($process.ProcessName -eq 'WindowsTerminal') {return $true}
1224
}
1325
return $false

0 commit comments

Comments
 (0)