How to use zsh Aliases for a Better Terminal Experience.

To continue with this tutorial, you should have iterm2, zsh and oh-my-zsh installed. If you do not have them already, you can look at my post how how to do that here.

To make zsh your default shell on iterm2, launch iterm2 and click on preferences. In preferences, select general and then profiles. In the general section of profile, select command and type /bin/zsh in the text box.

/bin/zsh is usually where zsh is installed on your computer.

Why aliasing?

One of the thing most developers would do is use a version control system for example git. To commit a staged file, the command is

git commit -m "Commit message"

Imagine typing this command for every commit. Tedious right?

What if you could just use the following instead of the above

gc "Commit message"

This would give you an idea of what aliasing is.

To use aliases, launch the terminal and open the zshrc file

vi ~/.zshrc

Scroll to the bottom of the file to add a new alias.

Sample .zshrc file

One simple alias is

alias ga="git add"
alias bci="brew cask install"

To save the aliases you just created, run the following on the terminal:

source ~/.zshrc

You can start using these short forms of longer commands on your terminal. Add as many aliases as you would want to.

--

--

Oluebube Princess Egbuna
Facebook Developer Circles Lagos

Oluebube, affectionately known as Bube, is an award-winning software engineer in the cloud native space, with over eight years of experience.