You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
826 B
PowerShell
26 lines
826 B
PowerShell
Set-PSReadlineKeyHandler -Key Tab -Function Complete
|
|
|
|
function prompt {
|
|
|
|
#depending on elevated permissions change the delimiter
|
|
$identity = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
|
|
if($identity.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
|
$delimiter = '#'
|
|
} else {
|
|
$delimiter = '$'
|
|
}
|
|
|
|
#shorten path with tilde if possible
|
|
#uses .Replace() to prevent regex
|
|
$cwd = (Get-Location).Path.Replace($HOME,'~')
|
|
|
|
'[{0}@{1} {2}]{3} ' -f $env:USERNAME.ToLower(),$env:COMPUTERNAME.ToLower(),$cwd,$delimiter
|
|
}
|
|
|
|
|
|
|
|
#check for old version
|
|
$version = ([String]$PSVersionTable.PSVersion).Substring(0,1)
|
|
if($version -lt 7) {
|
|
Write-Host -ForegroundColor Red 'start pwsh instead of powershell'
|
|
} |