Create aliases in .bash_profile to assign shortcuts for common Terminal commands

If you're in Terminal all the time, and you regularly type long commands, you can get back those precious moments of your life by creating aliases for those commands in your .bash_profile, which is a file in your Home directory that sets up and customizes your Terminal session.

Let's say you often browse to a directory that requires a lot of typing, such as:

$ cd ~/Dropbox/projects/octopress/source/_posts

You can create a shortcut by adding the following line to .bash_profile:

alias cdp="cd ~/Dropbox/projects/octopress/source/_posts"

Save the file, then either quit and relaunch Terminal, or refresh the changes by typing:

$ source ~/.bash_profile

From now on, to go to your Octopress posts directory, you can use this shortcut:

$ cdp

Another useful alias you can create is for opening files with your favorite text editor. In my case, it's Sublime Text 2, which already comes with an OS X Command Line tool called subl, but I find that typing subl is awkward. I'd rather type slt, so I created the following alias:

alias slt='open -a "Sublime Text 2"'

This allows me to use the following command to open a file with Sublime Text 2: $ slt ~/.bash_profile

I hope you found this tip useful, and if you have any bash tricks of your own, I'd love to hear about them.