PDA

View Full Version : Aliasing Bash Commands




Billicus
Mar 17, 2004, 06:38 PM
I've tried to alias bash commands by putting something similar to the in the .bashrc in my home directory:

alias new 'old command'

That doesn't seem to be working however. I remember there was an article about it in a recent issue of Macworld and/or MacAddict. Any ideas? :confused:



BrandonRP0123
Mar 17, 2004, 07:28 PM
I've tried to alias bash commands by putting something similar to the in the .bashrc in my home directory:
alias new 'old command'

That doesn't seem to be working however. I remember there was an article about it in a recent issure of Macworld and/or MacAddict. Any ideas? :confused:

There's two things that are of importance when doing this:


1. Bash reads two init files: .bash_profile and .bashrc. It is a peeve of mine to have two init files, so you can do:

ln -s .bashrc .bash_profile

from your home directory.

2. You've got the syntax almost right. Try something like:

# Old habits with old programs die hard. One day I'll switch to dig.
alias nsl='nslookup'
alias mxl='nslookup -q=mx'
alias vi='vim'



To get these files read immediately, type, for example ``source .bashrc''

To verify that the alias did in fact get set either use it or type 'alias' to see all the currently set aliases.


I hope this helps.

Billicus
Mar 17, 2004, 08:07 PM
That's perfect! :D Thanks for your help. :)