Skip to content
shellmap

aliasCreate a shortcut name for a longer command line across all 5 shells

Equivalents in every shell

Bashunix
alias ll='ls -la'

Builtin. Aliases are simple string substitution at the start of a command and do NOT take arguments — use a shell function for parameterised shortcuts.

Zshunix
alias ll='ls -la'

Same as bash. Zsh additionally supports `alias -g` (global, expanded anywhere on the line) and `alias -s` (suffix, by file extension) that bash lacks.

Fishunix
alias ll='ls -la'

Fish implements aliases AS auto-generated wrapper FUNCTIONS rather than string substitutions. Inspect the wrapper with `functions ll`. Persist via `alias --save ll=...` (writes to `~/.config/fish/functions/`).

PowerShellwindows
Set-Alias ll Get-ChildItem

CRITICAL: PowerShell aliases map a NEW NAME to an EXISTING command — they cannot carry flags. `Set-Alias ll "ls -la"` is invalid. For aliases with arguments, define a function: `function ll { Get-ChildItem -Force $args }`.

cmd.exewindows
doskey ll=dir /a $*

Cmd has no `alias` keyword. `doskey` macros work but are PER-SESSION only — persistence requires loading a `doskey` file via a `cmd /k` startup script or the `AutoRun` registry key.

Worked examples

Define a short name for a verbose command

Bash
alias gs='git status'
Zsh
alias gs='git status'
Fish
alias gs='git status'
PowerShell
function gs { git status @args }
cmd.exe
doskey gs=git status $*

List all currently defined aliases

Bash
alias
Fish
alias
PowerShell
Get-Alias
cmd.exe
doskey /macros

Persist an alias across new shell sessions

Bash
echo "alias gs='git status'" >> ~/.bashrc
Fish
alias --save gs='git status'
PowerShell
'Set-Alias gs Get-Service' >> $PROFILE

Gotchas

  • Bash aliases CANNOT take parameters. `alias greet='echo Hello $1'` will literally echo `Hello $1` — `$1` is empty at expansion time. Use a function instead.
  • Aliases are NOT expanded in non-interactive shells by default. A bash script started with `#!/usr/bin/env bash` won't see your `~/.bashrc` aliases unless you `shopt -s expand_aliases` first.
  • PowerShell `Set-Alias` aliases NAMES ONLY — you cannot bake flags or arguments into the alias. This is the single biggest porting pain when moving bash aliases. Use a `function` for anything with flags.
  • Fish `alias` creates a function, so `funcsave foo` after defining it writes the wrapper to disk. Listing the alias via `type` shows the wrapper-function body, which can be confusing for users coming from bash.
  • Cmd `doskey` macros do not persist — opening a new cmd window forgets all of them. Set `AutoRun` under `HKCU\Software\Microsoft\Command Processor` to a script that re-runs `doskey /macrofile=...` on every launch.

WSL & PowerShell Core notes

pwshPowerShell ships with built-in aliases that mimic Unix names: `ls`, `cat`, `pwd`, `cp`, `mv`, `rm`. On Linux/macOS pwsh, the Unix-name aliases are REMOVED so the system binaries win — meaning `ls -la` works on Linux pwsh but fails on Windows pwsh (where `ls` is `Get-ChildItem` and rejects `-la`).
WSLEach WSL distro has its own shell aliases (in `/home/$USER/.bashrc`); they are independent of any Windows pwsh aliases. Aliases defined inside WSL are NOT visible to `wsl.exe -- some-alias` invocations from Windows — wsl interop spawns a non-interactive shell that skips `.bashrc`.

Common tasks using alias

Related commands