Aliasing Bash Commands

Discussion in 'Mac Apps and Mac App Store' started by Billicus, Mar 17, 2004.

  1. Billicus macrumors 6502a

    Billicus

    Joined:
    Apr 3, 2002
    Location:
    Charles City, Iowa
    #1
    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:
     
  2. BrandonRP0123 macrumors regular

    Joined:
    Jul 28, 2003
    Location:
    San Francisco, CA
    #2
    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.
     
  3. Billicus thread starter macrumors 6502a

    Billicus

    Joined:
    Apr 3, 2002
    Location:
    Charles City, Iowa

Share This Page