How to Add an Alias in Macos Terminal

Adding an alias to the zsh shell in MacOS

Zsh is the default MacOS Shell. So to add an alias, we need to make changes to the zsh config file that is .zshrc.

Open .zshrc

.zshrc is typically present in the home folder ~/.zshrc

Adding alias

Add the alias to the .zshrc in the following syntax

alias aliasName="command"

Source .zshrc

After saving, source .zshrc using the following command in the Terminal

$ source ~/.zshrc