|
|
|
@ -3,21 +3,26 @@ Set-PSReadlineKeyHandler -Key Tab -Function Complete
|
|
|
|
|
Set-PSReadlineKeyHandler -Key Ctrl+d -Function ViExit
|
|
|
|
|
#endregion keybindings
|
|
|
|
|
|
|
|
|
|
function prompt {
|
|
|
|
|
#region prompt dependencies
|
|
|
|
|
#set part of the prompt beforehand to optimize the prompt function
|
|
|
|
|
|
|
|
|
|
#depending on elevated permissions change the delimiter
|
|
|
|
|
$identity = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
|
|
|
|
|
if($identity.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
|
|
|
|
#depending on elevated permissions change the delimiter
|
|
|
|
|
$identity = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
|
|
|
|
|
if($identity.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
|
|
|
|
$delimiter = '#'
|
|
|
|
|
} else {
|
|
|
|
|
} else {
|
|
|
|
|
$delimiter = '$'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$username = $env:USERNAME.ToLower()
|
|
|
|
|
$computername = $env:COMPUTERNAME.ToLower()
|
|
|
|
|
#endregion prompt dependencies
|
|
|
|
|
function prompt {
|
|
|
|
|
#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
|
|
|
|
|
'[{0}@{1} {2}]{3} ' -f $username,$computername,$cwd,$delimiter
|
|
|
|
|
}
|
|
|
|
|
function Get-BetterADUser {
|
|
|
|
|
param (
|
|
|
|
|