From 39f6d2380aef53c04b78e171519f9b749807bce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=B6rner=2C=20Simon?= Date: Tue, 13 Aug 2019 15:01:58 +0200 Subject: [PATCH] set vi mode in profile.ps1 and bashrc --- bashrc | 2 ++ profile.ps1 | 82 +++++++++++++++++++++++++++-------------------------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/bashrc b/bashrc index 300e3ff..9d85b4b 100644 --- a/bashrc +++ b/bashrc @@ -83,3 +83,5 @@ alias d-u='sudo apt update && sudo apt full-upgrade && sudo apt --purge autoremo alias compress-music='nice -n19 /home/lub/git/scripts/compress-music.sh' alias pp='git pull -r && git push' alias statdiff='git status && git diff --staged' + +set -o vi \ No newline at end of file diff --git a/profile.ps1 b/profile.ps1 index 1ec5e37..9496dba 100644 --- a/profile.ps1 +++ b/profile.ps1 @@ -1,41 +1,43 @@ -#region keybindings -Set-PSReadlineKeyHandler -Key Tab -Function Complete -Set-PSReadlineKeyHandler -Key Ctrl+d -Function ViExit -#endregion keybindings - -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 -} -function Get-BetterADUser { - param ( - [Parameter(Mandatory=$true, - Position=0)] - [string] - $SearchTerm, - [string] - $Server = '{0}:3268' -f $env:USERDNSDOMAIN - ) - - $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' +Set-PSReadLineOption -EditMode Vi + +#region keybindings +Set-PSReadlineKeyHandler -Key Tab -Function Complete +Set-PSReadlineKeyHandler -Key Ctrl+d -Function ViExit +#endregion keybindings + +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 +} +function Get-BetterADUser { + param ( + [Parameter(Mandatory=$true, + Position=0)] + [string] + $SearchTerm, + [string] + $Server = '{0}:3268' -f $env:USERDNSDOMAIN + ) + + $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' } \ No newline at end of file