Powershell#
A collection of some powershell-snippets I found useful, can be found under:
Constructing an alias with arguments#
You can use the builtin-args variable for that.
function DotFilesRepo(){
$base = "git.exe --git-dir=$env:USERPROFILE\repos\dotfiles\ --work-tree=$env:USERPROFILE"
$cmd = "$base $args" # The $args-variable is builtin and gets all arguments. Discoverd by accident.
Invoke-Expression -Command $cmd
}
function DotFilesReposStatus(){
dfr status
}
Set-Alias -Name dfr -Value DotFilesRepo
Set-Alias -Name dfrs -Value DotFilesReposStatus
Aliases#
When constructing an alias with the corresponding function, keep in mind that powershell
is not case-sensitive.
That means, Set-Alias -Name wiki -Value Wiki
would set alias that overwrites the function.
My approach to this is to add the appropriate verb to the function name, e.g. Set-Alias -Name wiki -Value EnterWiki
.