-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMicrosoft.VSCode_profile.ps1
30 lines (26 loc) · 1.07 KB
/
Microsoft.VSCode_profile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# VSCode profile needs to skip prompt color and Write-Host because the
# session startup hangs on the parallel prompt startup. Go super-simple.
# Note the standard integrated prompt will use the regular profile and
# may hang until you issue the first command and/or hit enter.
& $PSScriptRoot/ProfileCommon.ps1
Set-Content Function:prompt {
# Determine if the user is admin, so we color the prompt green or red.
$isAdmin = $false
$isDesktop = ($PSVersionTable.PSEdition -eq "Desktop")
if ($isDesktop -or $IsWindows) {
$windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$windowsPrincipal = new-object 'System.Security.Principal.WindowsPrincipal' $windowsIdentity
$isAdmin = $windowsPrincipal.IsInRole("Administrators") -eq 1
}
else {
$isAdmin = ((& id -u) -eq 0)
}
if ($isAdmin) { $adminFlag = " [Admin]" }
# Write PS> for desktop PowerShell, pwsh> for PowerShell Core.
if ($isDesktop) {
return "PS$adminFlag $pwd>"
}
else {
return "pwsh$adminFlag $pwd>"
}
}