set vi mode in profile.ps1 and bashrc
parent
06d2807d7c
commit
39f6d2380a
@ -1,41 +1,43 @@
|
|||||||
#region keybindings
|
Set-PSReadLineOption -EditMode Vi
|
||||||
Set-PSReadlineKeyHandler -Key Tab -Function Complete
|
|
||||||
Set-PSReadlineKeyHandler -Key Ctrl+d -Function ViExit
|
#region keybindings
|
||||||
#endregion keybindings
|
Set-PSReadlineKeyHandler -Key Tab -Function Complete
|
||||||
|
Set-PSReadlineKeyHandler -Key Ctrl+d -Function ViExit
|
||||||
function prompt {
|
#endregion keybindings
|
||||||
|
|
||||||
#depending on elevated permissions change the delimiter
|
function prompt {
|
||||||
$identity = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
|
|
||||||
if($identity.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
#depending on elevated permissions change the delimiter
|
||||||
$delimiter = '#'
|
$identity = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
|
||||||
} else {
|
if($identity.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
||||||
$delimiter = '$'
|
$delimiter = '#'
|
||||||
}
|
} else {
|
||||||
|
$delimiter = '$'
|
||||||
#shorten path with tilde if possible
|
}
|
||||||
#uses .Replace() to prevent regex
|
|
||||||
$cwd = (Get-Location).Path.Replace($HOME,'~')
|
#shorten path with tilde if possible
|
||||||
|
#uses .Replace() to prevent regex
|
||||||
'[{0}@{1} {2}]{3} ' -f $env:USERNAME.ToLower(),$env:COMPUTERNAME.ToLower(),$cwd,$delimiter
|
$cwd = (Get-Location).Path.Replace($HOME,'~')
|
||||||
}
|
|
||||||
function Get-BetterADUser {
|
'[{0}@{1} {2}]{3} ' -f $env:USERNAME.ToLower(),$env:COMPUTERNAME.ToLower(),$cwd,$delimiter
|
||||||
param (
|
}
|
||||||
[Parameter(Mandatory=$true,
|
function Get-BetterADUser {
|
||||||
Position=0)]
|
param (
|
||||||
[string]
|
[Parameter(Mandatory=$true,
|
||||||
$SearchTerm,
|
Position=0)]
|
||||||
[string]
|
[string]
|
||||||
$Server = '{0}:3268' -f $env:USERDNSDOMAIN
|
$SearchTerm,
|
||||||
)
|
[string]
|
||||||
|
$Server = '{0}:3268' -f $env:USERDNSDOMAIN
|
||||||
$filter = 'UserPrincipalName -like "*{0}*" -or Name -like "*{0}*"' -f $SearchTerm
|
)
|
||||||
|
|
||||||
Get-ADUser -Filter $filter -Server $Server
|
$filter = 'UserPrincipalName -like "*{0}*" -or Name -like "*{0}*"' -f $SearchTerm
|
||||||
}
|
|
||||||
|
Get-ADUser -Filter $filter -Server $Server
|
||||||
|
}
|
||||||
#check for old version
|
|
||||||
if($PSVersionTable.PSVersion.Major -le 5){
|
|
||||||
Write-Host -ForegroundColor Red 'start pwsh instead of powershell'
|
#check for old version
|
||||||
|
if($PSVersionTable.PSVersion.Major -le 5){
|
||||||
|
Write-Host -ForegroundColor Red 'start pwsh instead of powershell'
|
||||||
}
|
}
|
Loading…
Reference in New Issue