Command line aliases

If you find yourself typing the same long strings in command line everyday, chances are that you’ll benefit from making some aliases, or shortcuts. To do so, go to your home directory and look for a file called .bash_profile. Open it using your favorite text editor and add an alias using the following format:

alias gla='git config --get-regexp alias | sort'

This handy alias just prints out a list of my Git aliases. An alias for an alias!


You can also set longer functions to perform a sequence of commands. Below, I’ve created an alias to leggo that will set up the servers I need at my job to work on localhost and run tests. I also have tab aliased to open up a new tab in my iTerm, which is a SUPER handy function. I chose not to display it because it’s long, but if you want to use it yourself, you can find it here.

alias redis='redis-server'
alias pgstart='postgres -D /usr/local/var/postgres'

function leggo {
  tab pgstart
  tab redis
  tab rails s
  tab sidekiq
  tab
}

Practice command line

Being a master of the command line is an essential skill for any developer. Use these tools to get started with the command line and hone your craft!

Learn Code The Hard Way

This book is a great introduction into using the command line. If you’ve never touched the Terminal before, this is for you.

iTerm2

iTerm2 is a great alternative to the Terminal on MacBooks. It’s highly customizable and has some cool features that you can explore.

iTerm2 Shortcuts

My friend, Zach Alewel, has a nice blog post on some iTerm2 shortcuts you can add to your profile. If you’re lazy, I recommend taking a look at these.

GitHug

GitHug is an amazing tool for practicing Git at the command line. If you’re unfamiliar with Git, I would read up on it a little before diving in. Checkout my blog posts about Git, they’ll help!

vimtutor

This is already installed on your computer. Go ahead and type ‘vimtutor’ at the command line. It will pop up a separate window to teach you the basics of using the built in text editor.