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
}
Advertisements

One thought on “Command line aliases

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s