Alias
Set an Alias
ps1
New-Alias <alias> <cmd_name>
1
NOTE
New-Alias
throws when the alias already exist while Set-Alias
will overrides it.
Override an Alias
ps1
Set-Alias <alias> <cmd_name>
1
Checkout Alias
- Check out by alias
ps1
Get-Alias <alias>
1
Or use Get-Command
ps1
Get-Command <alias>
1
- Check out by command name
ps1
Get-Alias -Definition <cmd_name>
1
Builtin Aliases
Powershell ships with some builtin aliases, checkout by this command:
ps1
Get-Alias | Where-Object { $_.Options -match 'ReadOnly|Constant' }
1
NOTE
Do not use custom aliases for public repository.
Differ from Bash
Alias in powershell is only a name alias for a command, it can never take any predetermined parameters or flags like in bash.
sh
alias gl='git log' # fine
1
ps1
New-Alias gl 'git log' # not allowed!
1