DEV Community

StuartCreed
StuartCreed

Posted on

How to add aliases to your terminal on Mac OS

A source of potential confusion

As a default MacOS now (since the beginning of 2019) ships with zsh shell (compiler in /bin/zsh) rather than bash shell (compiler in /bin/bash) in the terminal. This means that if you look in forums etc for information about aliases for MacOS and .bashrc and .bash_profile files are mentioned this is no longer relevant. You can change the default back to bash but this is not recommended, zsh is deemed better (generally) hence why they changed the default. I personally have deleted the .bashrc and .bash_profile file in my home directory (cd or cd ~ to get to your home directory) to avoid confusion.

To add an alias for zsh

cd ~
nano .zshrc
Enter the alias e.g:
alias l='ls -lrtah'
Press Ctrl + X and then Save.
To make these changes have affect you then need to run:
source .zshrc

Now if I run l in the terminal ls -lrtah will be run instead

Discussion (2)

Collapse
kverma_dev profile image
Kunal Verma

Thank you for the article !!
This really helped me 🙂

Collapse
stuartcreed profile image
StuartCreed Author

Glad it helped 🙂