Unix aliases for long commands
I often tell my students that I am lazy as a programmer. I typically try to convince them that this is a good thing. The point I'm trying to make, of course, is that often the best line of code is the one you don't have to write.
Unix Aliases
The same principle applies when working in Unix. Many commands in Unix have numerous toggles, switches, and arguments. Some of these commands get quite long. Many of them are long commands I execute frequently. To minimize all that typing, you can create aliases. If you are at the command line (which you reach in Mac OS X by running the Terminal application), you can create an alias like so:
alias ll="ls -al"
Now, I can simply type "ll" at the command line instead of typing the longer "ll -al".
Saving Aliases
That is a nice start, but if you quit Terminal and return later, "ll" doesn't work any more. To make these aliases more permanent, you want to edit your .profile file (on other Unix flavors, you might edit .bashrc instead).
Listing: ~/.profile
# Aliases for commonly used commands alias ll="ls -al" alias iw="ssh markf@www.istarelworkshop.com" alias bnr="ssh markf@www.bignerdranch.com" alias bp="ssh broker@www.brokerpower.com"
There are two things to note here: first, spacing is important. Make sure there are no spaces on either side of the equal sign. Second, when you edit ~/.profile this way, the shortcuts will not be available to you until you open a new Terminal window.