a simple intro to alias in macosx (unix) (+ doskey in windows)
From the java developer's perspective, it is very often that you will have to deal with long project strcuctures and even longer ant task names,just to get something to execute or cd to a specific folder. I was getting a bit tired when everyday I was dealing with something like that
1ant -f /Volumes/secondary/myproject/mySubprojectEar/build-all.xml database.recreate.keepUser
several other tasks or a combination of them. I could not be bothered. So I started using the alias functionality offered in the MacOSX Terminal and in any other Unix compatible shell system.
I wanted to re-load my aliases every time I was rebooting or having a new session so in one step do the following.
- edit your .profile in your home folder
1vi /Users/username/.profile
- add the alias you want in any command you want, the format is alias aliasname ='command_ .
1alias dbrecreate ='ant -f /Volumes/secondary/myproject/mysubprojectear/build-all.xml db.recreate'
2alias cdtoproj='cd /Volumes/secondary/myproject'
-
Save your .profile and open a new terminal
-
type dbrecreate and your ant task should be executing or just type > cdtoproj and you will cd to the above directory!
If you don't your aliases reloaded or associated with your profile you can issue the same commands from your command line and they will be valid as long as your current terminal session is valid.
For windows users :P there is the old doskey command.(winNT, 2k,XP). I think I have read somewhere that in Win7 the new Powershell has something as well.So if you want to do the same you have to type something like
1> c:\\> doskey reachappear = cd c:\\myproject\\myearproj\\
you can save all your macros (this is how they are called in M$ world) by doskey /M> macros.txt and reload them using doskey /File c:\:macros.txt