Alias
Specify the same alias cross shell.
Syntaxโ
alias:
- name: a
value: aliae
- name: hello-world
value: echo "hello world"
type: function
- name: sync
value: "!git fetch origin; git rebase origin/HEAD"
type: git
- name: pyfmt
value: "import sys; print(' '.join(sys.argv[1:]))"
type: python
- name: plfmt
value: "print join(' ', @ARGV)"
type: perl
Aliasโ
| Name | Type | Description |
|---|---|---|
name | string | the alias name |
value | string | the command(s) you want to execute, supports templating |
type | string |
|
if | string | golang template conditional statement, see if |
python and perl alias types are not available in tcsh.
Shell specific configurationโ
- powershell
| Name | Type | Description |
|---|---|---|
description | string | specifies a description of the alias |
force | boolean | use the force parameter to change or delete an alias that has the Option parameter set to ReadOnly. The Force parameter cannot change or delete an alias with the option parameter set to Constant |
option | string | see the PowerShell documentation |
scope | string | see the PowerShell documentation |
Expected output by shell and alias typeโ
The examples below use:
alias:
- name: foo
value: bar
type: command
- name: fn
value: bar
type: function
- name: pyfoo
value: print(123)
type: python
- name: plfoo
value: print qq(123)
type: perl
- name: h
value: log --oneline --graph --decorate --all
type: git
git aliases are written with git config --global, not as shell alias syntax. Most shells emit:
git config --global alias.h 'log --oneline --graph --decorate --all'
Nushell uses a raw string variant:
git config --global alias.h r#'log --oneline --graph --decorate --all'#
- bash
- zsh
- fish
- pwsh
- nu
- tcsh
- xonsh
- cmd
alias foo="bar"
fn() {
bar
}
pyfoo() {
python -c "print(123)" "$@"
}
plfoo() {
perl -e "print qq(123)" "$@"
}
alias foo="bar"
fn() {
bar
}
pyfoo() {
python -c "print(123)" "$@"
}
plfoo() {
perl -e "print qq(123)" "$@"
}
alias foo "bar"
function fn
bar
end
function pyfoo
python -c "print(123)" $argv
end
function plfoo
perl -e "print qq(123)" $argv
end
Set-Alias -Name foo -Value "bar"
function fn() {
bar
}
function pyfoo() {
python -c "print(123)" $args
}
function plfoo() {
perl -e "print qq(123)" $args
}
alias foo = bar
def fn [] {
bar
}
def pyfoo [...args] {
python -c "print(123)" ...$args
}
def plfoo [...args] {
perl -e "print qq(123)" ...$args
}
alias foo 'bar';
alias pyfoo 'python -c "print(123)"';
alias plfoo 'perl -e "print qq(123)"';
function aliases are not supported in tcsh.
aliases['foo'] = 'bar'
@aliases.register("fn")
def __fn():
bar
@aliases.register("pyfoo")
def __pyfoo(args):
import subprocess
subprocess.run(["python", "-c", "print(123)", *args], check=False)
@aliases.register("plfoo")
def __plfoo(args):
import subprocess
subprocess.run(["perl", "-e", "print qq(123)", *args], check=False)
macrofile:write("foo=bar", "\n")
macrofile:write("pyfoo=python -c \"print(123)\" $*", "\n")
macrofile:write("plfoo=perl -e \"print qq(123)\" $*", "\n")
function aliases are not supported in cmd.