Sitemap
Zaid Hanania

Zaid Hanania

Front-end Web Developer - Computer Engineering student at the University of Toronto — http://zaid.io/

Creating Aliases for Your Command Line

Are you getting sick of typing the same commands in your command-line interface(CLI)? Well, now you don’t have to! I’ve just started using git on command line and I hate having to keep typing in the same commands over and over again.

What are aliases?

Aliases are like shortcuts for commands. For example, instead of having to type in git push origin master, now I just put gpom. Much better, right?

Creating your own

It is very easy to create aliases. First, you need your CLI open. Now, just type nano ~/.bash_profile then press enter. nano is just a command-line text editor. A text file will open in your CLI, it might be empty or it might have some text in it but that’s okay. Go down to the end of the file using the arrow key. Now, it’s time to create your aliases!

Get Zaid Hanania’s stories in your inbox

Join Medium for free to get updates from this writer.

In order to create an alias you type in:

alias [the alias name you want]=‘[the actual command]’

For example, for me to use gpom instead of git push origin master, I wrote:

alias gpom=‘git push origin master’

You can write as many aliases as you want. When you’re done, use control+O to save your changes, press enter without changing the filename, then exit using control+X. In order to use these aliases, you will have to quit your CLI and reopen it. Enjoy!

Written by Zaid Hanania

Front-end Web Developer - Computer Engineering student at the University of Toronto — http://zaid.io/