.bashrc

Discussion in 'General Mac Discussion' started by starrin, Jan 8, 2005.

  1. starrin macrumors member

    Joined:
    Aug 22, 2004
    #1
    I am trying to add certain extra directories to my path when I open a Terminal window -- my understanding is that I would put this in my .bashrc file. The problem is that I do not see this file in my home directory---should I?

    If I had to create one -- is there an example someone can point me to in order to make it right?

    Thanks in advance.
     
  2. jsw Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #2
    You need to create one; here is a dated but still relevant example.

    Good luck, and report back if you have any problems!
     
  3. jsw Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #3
  4. starrin thread starter macrumors member

    Joined:
    Aug 22, 2004
    #4
    Hi and thank you for your help --

    I created a .bashrc file and placed it in my home directory and my settings are not coming through -- here are my settings - again thanks for any input:

    # Set JAVA_HOME
    export JAVA_HOME=/Library/Java/Home

    # Set Classpath
    export CLASSPATH=/Users/jason

    # Entries for ANT
    export ANT_HOME=/Users/jason/Development/SoftwareDownloads/apache-ant-1.6.2
    export PATH=$PATH:$ANT_HOME/bin
    export CLASSPATH=$CLASSPATH:$ANT_HOME

    # Entries for Maven
    export PATH=$PATH:/Users/jason/Development/SoftwareDownloads/maven-1.0.2/bin
    export MAVEN_HOME=/Users/jason/Development/SoftwareDownloads/maven-1.0.2
     
  5. Westside guy macrumors 601

    Westside guy

    Joined:
    Oct 15, 2003
    Location:
    The soggy side of the Pacific NW
    #5
    If you've got an existing .bash_profile file, you should add the following to it:

    Code:
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
            . ~/.bashrc
    fi
    
     
  6. starrin thread starter macrumors member

    Joined:
    Aug 22, 2004
    #6
    Hi -- searching other posts I came across that -- but I have no .bash_profile file

    I have a .profile file....

    Thanks for the help
     
  7. starrin thread starter macrumors member

    Joined:
    Aug 22, 2004
    #7
    Okay -- I changed the name of my .bashrc file to .bash_profile (and added quotes to my exports) -- it all works

    So -- should I keep my .bashrc file and make a .bash_profile file call it with the code above? What does that do for me?


    Thanks in advance.
     
  8. jsw Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #8
    Dunno. :confused:

    I thought that the profile always called the resource file during login (see here) but I'm not even vaguely a guru in this area.
     
  9. Westside guy macrumors 601

    Westside guy

    Joined:
    Oct 15, 2003
    Location:
    The soggy side of the Pacific NW
    #9
    Short answer is: yes, do it. :D

    .bash_profile gets called when your shell is a login shell (which, if you're using Terminal, it generally is). However it won't get invoked by non-login shells; but .bashrc will.

    This probably won't matter to you in the least. :D But it is more flexible, if sometime in the future you get bored and start playing with bash.
     

Share This Page