Improve PowerShell prompt for older version
This commit is contained in:
parent
c05031356d
commit
5680247eff
1 changed files with 11 additions and 7 deletions
|
@ -4,18 +4,22 @@
|
||||||
# C:\Users\USERNAME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
|
# C:\Users\USERNAME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
|
||||||
|
|
||||||
function Prompt {
|
function Prompt {
|
||||||
if ($IsWindows -and $PSVersionTable.PSVersion -gt [System.Version]"6.0") {
|
if ($IsWindows -or ($env:OS -eq "Windows_NT")) {
|
||||||
|
[string]$monoPrompt = ""
|
||||||
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
||||||
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||||
"`e[1m" + $env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "# `e[0m"
|
$monoPrompt = $env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "# "
|
||||||
} else {
|
} else {
|
||||||
"`e[1m" + $env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "> `e[0m"
|
$monoPrompt = $env:USERNAME + "@" + $env:COMPUTERNAME.ToLower() + "> "
|
||||||
}
|
}
|
||||||
}
|
if ($PSVersionTable.PSVersion -gt [System.Version]"6.0") {
|
||||||
elseif ($IsLinux) {
|
"`e[1m" + $monoPrompt + "`e[0m"
|
||||||
|
} else {
|
||||||
|
$monoPrompt
|
||||||
|
}
|
||||||
|
} elseif ($IsLinux) {
|
||||||
"`e[1m" + $(id -un) + "@" + $(hostname -s) + "> `e[0m"
|
"`e[1m" + $(id -un) + "@" + $(hostname -s) + "> `e[0m"
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
"PS> "
|
"PS> "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue