Save time with aliases

2009 November 23

There are a lot of commands that I run every day over the terminal. Once I see a command I run more than once a day or more often than usual I usually create a shortcut for it.

Some of these shortcuts are everything from restarting apache, cd’ing to my web root, ssh’ing to a server, etc. Below are a few that I have in my .shortcuts file.

# restart apache
# $ r
alias 'r=sudo apachectl restart'

# I'm used to running gvim and this just maps the command 'gvim' to mvim'
# $ gvim .
# $ gvim directory_name
alias 'gvim=mvim'

# ssh to a common server
# add passwordless login for a faster connection, be careful though.
# $ s
alias s='ssh user@yoursite.com'

# cd into a common client work folder
# $ john
alias john='cd /Users/nick/web/freelance/john.com'

# generate a bunch of random passwords, it's better than go123...
# pwgen is an awesome password generation tool, I highly recommend it.
$ $ pass
alias pass='pwgen -s -n 10'

# open the specified location in finder and highlight it. Helpful for when something would be faster through the gui or you need to view images or pdfs.
# $ o images
alias o='open --reveal'
# 'o' is faster than 'open'
# open web
alias open='o'

# kill a process immediately.
# e.g. kp ruby
# e.g. kp firefox-bin
alias kp='killall -9'

# quickly view the last 100 lines of the apache error log
# $ log
alias log='tail -n 100 /var/log/apache2/error_log

To load your .shortcuts file when you open up the terminal just put this line in your .bashrc or .profile file.

. ~/.shortcuts

Also, you have to use a utility like Spotlight, Quicksilver or Launchbar. Get one of them and use it at least for the ability to quickly launch applications. Hide your dock or taskbar and rely on alt-tab(switch applications) and alt-~(switch windows for current application)

For example, with Spotlight which comes with OS X all you have to do is hit Alt+Space type ‘Fire’ and hit Enter and Firefox will open, no mouse required. Mice are gross and smell, keep your hands on the keyboard where they belong.

No comments yet

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS