I know that in bash you can set up aliases in a .bash_aliases file so that the command you type doesnt need to be a command stored in the binaries in the system. Is there any way I can get aliases into zsh?


You can do it by the "alias" command with this syntax:

alias [ -gmrL ] [ name[=value] ... ]

For "gmrL" switches, see this guide, which is my reference.
For each name, with no value, zsh will print the name and what it is aliased to previously. With no arguments at all, alias prints the values of ALL defined aliases.

To define one or more aliases, simply enter:

alias name1=value1 name2=value2 ... nameX=valueX

For each name with a corresponding value, zsh defines an alias with that value. For further info, check out that link. ;-)

  • That document answered my question exactly. Thanks much. – Thomas Ward Mar 21 '11 at 3:22
  • That link is down. – Soham Chowdhury Apr 14 '14 at 10:52
  • updated the link. – sazary Apr 14 '14 at 17:54
  • 10
    this answer misses the part about where to persist the aliases, Kurtosis answer includes it (.zshrc). – Felix Jul 31 '14 at 9:06
  • 6
    I use ~/.profile to store all aliases I care about and source ~/.profile it from ~/.zshrc. – danba Nov 12 '18 at 20:00

I go back and forth between bash and zsh, and use the same .aliases file for both. They share the same basic alias syntax, so you can create a .aliases file and link it to .bashrc and .zshrc:


if [ -f ~/.aliases ]; then
    . ~/.aliases


source $HOME/.aliases

FWIW this can also be done with environment variable declarations, in a separate .env file.

  • 1
    I just added source ~/ .bash_aliases to the end of .zshrc, so all aliases are working both on bash and zsh – talsibony Feb 3 '17 at 9:04
  • @talsibony like this: ~/ .bash_aliases I need little help please if you are there, respond – lewis4u Apr 13 '17 at 11:26
  • @lewis4u There should not be a space between ~/ and .bash_aliases. It should be exactly ~/.bash_aliases. – Kurtosis Jun 16 '17 at 20:54
  • 2
    Your links are broken.. – Ilan.b Aug 19 '19 at 8:48
  • Both links are broken. Wouldn't both the same as [ -r "$HOME/.aliases" ] && source "$HOME/.aliases"? (nice doc) – Pablo Bianchi Apr 7 '20 at 16:09

You generally put them in ~/.zshenv. But many programs use /bin/sh (usually bash) instead of $SHELL to execute shell commands, so for it to work everywhere you will probably need to put the bash equivalent of the alias into ~/.bash_aliases anyway.

  • This is for my user account only, so this does not need to be copied to the ~/.bash_aliases file. – Thomas Ward Mar 20 '11 at 18:02
  • 1
    According to this, aliases should go in .zshrc because .zshenv is "Read every time" -- "this file is read even when Zsh is launched to run a single command." – AWhitford Oct 16 '20 at 22:17


add this line at the bottom of the file

Assuming that your aliases located in ~/.profile

source ~/.profile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.