Alias: a guide to powershell and aliases
To Set An Alias
set-alias -name gito -value git_off
To Check an Alias
get-command *cls*
...produces a list of not just aliases but commands that match your pattern. (So i sometimes prefer it over get-alias
though it can produce unwanted results.)
CommandType Name
=========== ====
Alias cls -> Clear-Host
To only find aliases for a command
Wonder what aliases exist for a command (or commands)? add the -def
parameter to get-alias
get-alias -def "push-location"
Aliases can't have parameters: make tiny functions instead
in bash, an alias can include parameters. Not so in PowerShell. It's just an abbreviation.
set-alias tf "tree /f" # this doesn't work!
(bash allows that kind of thing, as does git)
To create an alias with parameters you're advised to instead create a tiny function in your $PROFILE
.
e.g.
function tf() {
tree /f
}
Tiny_Functions are cool! But over time they don't stay tiny. They grow it into a cmdLet, then eventually they are put it into a module and they leave $env:home
.