For those who are new to working with Unix, I want to take a moment to introduce aliases. The simplest means to think of an alias is as a text shortcut, used inside a Terminal window, to represent one or more commands. On second thought, maybe that isn’t the simplest means to describe an alias. Let me try again using an example…
I have an alias configured on my system with the name cls that is a shortcut for the command clear. Now, saving two keystokes is pretty trivial, however, given that you can assign an alias to commands that are much more involved, as well as use an alias to represent more than one command, all of a sudden it starts to make sense. Below is a list of the aliases that I am currently using:
alias ab='ant build.plugins'
alias ad='ant deploy.plugins'
alias j='cd ~/Desktop/jive_clearspacex_standalone_1_6_0'
alias jivep='cd ~/Desktop/jive_clearspacex_standalone_1_6_0/plugins/plugins'
alias ls='ls -al'
alias mjxtmp='cd /tmp/mojax.cache/localhost9180/source'
alias zd='sudo sh /etc/daily'
alias zm='sudo sh /etc/monthly'
alias zw='sudo sh /etc/weekly'
I generally find aliases helpful when I need to navigate to various directories and also when I need to run the same command(s ) repeatedly. You can see from the aliases above that I’ve been working on creating plugins for Clearspace, which involves starting/stopping an instance of Clearspace on my machine, moving between directories and running ant scripts to build and deploy. Using aliases save me a great deal of time and trouble typing in the same commands over and over.
You create aliases by editing .bash_profile in your home directory. Given that the filename begins with a “.” it is by default hidden by the operating system. You can configure Finder to show all files (including hidden/system files) using the Finder Preferences dialog:
You can learn more about working with aliases by accessing its manpage (type man alias in a Terminal) or viewing the alias command at the Linux Information Project.
The cls command mentioned earlier is more than simply a shortcut for clear, it’s also a throwback to my days working with DOS.