Powershell config

From wikinotes

rcfile

$env:USERPROFILE\Documents\WindowsPowerShell\Microsoft.Powershell_profile.ps1
powershell's rcfile

The powershell has an rcfile, just like a real shell. type $profile to see where your shell is reading it from.

vi mode

# install powershell readline module
Install-Module PsReadline -Scope CurrentUser

# edit your powershell rcfile
ise $PROFILE

Add to your $PROFILE file:

if ($host.Name -eq 'ConsoleHost'){
    Import-Module PSReadLine
    Set-PSReadlineOption -EditMode Vi
    Set-PSReadlineKeyHandler -Key Tab -Function Complete

    Set-PSReadlineKeyHandler -Chord Alt+k -Function ViCommandMode
    Set-PSReadlineKeyHandler -Chord Alt+j -Function ViCommandMode
    Set-PSReadlineKeyHandler -Chord Alt+h -Function ViCommandMode
    Set-PSReadlineKeyHandler -Chord Alt+l -Function ViCommandMode

}

aliases

Set-Alias ls get-location   # ls is now an alias of get-location

unix aliases:

add to your $PROFILE

set-alias ll get-childitem
set-alias lal get-childitem

function symlink( $src, $dst ){ New-Item -Path $dst -ItemType SymbolicLink -Value $src }
function touch { echo $null >> $args }