Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to install rvm on my Snow Leopard machine.

It says I need to add a line to my .bashrc file (I'm using bash) but where is my .bashrc file?

share|improve this question
You should put your solution in an answer and accept it (You'll have to wait a day or two before SU allows you to do so) That way people with the same problem can look at the question can see that it has an answer. –  Nifle May 30 '10 at 22:39
Don't forget to accept an answer for this question. –  Stefan Lasiewski Jun 21 '10 at 4:41
His solution is no different from the top voted answer.. –  David Cowden Jul 2 '12 at 15:15

5 Answers 5

Regarding the problem with .bashrc above:

On most systems, ~/.bashrc is only used when starting an interactive non-login shell. However, when you start up a new shell it is often an interactive login shell. Since this is a login shell, the .bashrc is ignored. To keep the environment consistent between non-login and login shells, you must source the .bashrc from your .profile or your .bash_profile .

See the Bash Reference Manual, section 6.2 Bash Startup Files

Invoked as an interactive login shell, or with --login

When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

Invoked as an interactive non-login shell

When an interactive shell that is not a login shell is started, Bash reads and executes commands from ~/.bashrc, if that file exists.

So, typically, your ~/.bash_profile contains the line

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

after (or before) any login-specific initializations.

On my Mac (Running Leopard), there was no line to source ~/.bashrc . I had to add this functionality on my own.

On some systems, .bashrc is sourced from the global /etc/profile or /etc/bash_profile , or is done using the template files from /etc/skel .

share|improve this answer
This link gives a good overview of the types of shells and when startup files are loaded - hacktux.com/bash/bashrc/bash_profile –  studgeek Jun 24 '12 at 16:55
up vote 36 down vote accepted

So turns out that on Mac OS X Snow Leopard as well as Mac OS X Lion, the file that's loaded is called .profile, not .bashrc.

What you want to do is create a file in ~/.profile and call it .profile (if it doesn't already exists).

Put whatever information you needed to load with each instance of bash there (Thanks, thepurplepixel).

A couple of side notes:

  1. The period in front of the file marks it as invisible to Finder and the ls command by default. To list invisible files using the ls command from Terminal, use the -a as a parameter as such: ls -a
  2. The ~ symbol stands for /Users/YourUserName where YourUserName is your username's shortname.

Edit: Chris Page notes (correctly) that whatever you place in a .profile file will apply to whatever shell you're using (i.e. zhs, bash, et cetera). If you want the contents to affect only the bash shell, place the contents in a .bash_profile file instead of a .profile file.

share|improve this answer
Your question was answered [correctly] on June 1 2010 -- one day after you asked it. Over a year later, you come back and provide the exact same answer and accept your own answer... –  David Cowden Jul 2 '12 at 15:14
Actually his answer does add more detail than the answer given on June 1 2010. He specifically addresses the issue on Mac OS X which I found helpful. –  webworm Jul 25 '13 at 11:05
Note that if a .bash_profile already exists in your home directory, then .profile file will not be read! –  Phani Jul 1 '14 at 19:51

You have to make your own .bashrc. You can simply use a text editor to make a file called .bashrc (no extension) with the contents you want and save it in your home directory (/Users/YourUserName/).

share|improve this answer
actually, that didn't work, but you did send me in the right direction by telling me to make my own file. The file that worked on a Snow Leopard configuration was .profile, not .bashrc (which is for some reason not loaded in this OS). I'll post detailed instructions in the question. Thanks! –  Yuval May 30 '10 at 21:17
@Yuval: By default, a .bashrc will work, but only if there is no .profile. I guess ~/.profile exists by default, though. Glad I could help! (And you should put your solution in an answer and accept it for future readers of this question). –  squircle May 31 '10 at 0:09
I think your comment about only if there is no .profile is incorrect. .bashrc will work within a interactive non-login shell, or if it sourced from .profile (.bash_profile is probably a better place, since .profile is for the Bourne shell). .profile is used during an interactive non-login shell. –  Stefan Lasiewski Jun 1 '10 at 18:34
@Stefan That sounds correct, then. I'm not an expert :) –  squircle Jun 1 '10 at 19:11
Nobody is ;). This stuff (.bashrc vs .profile vs. .bash_profile vs. .bash_login vs. interactive login shell vs interactive non-login shell vs non-interactive shell) is confusing, and it's broken and overridden by many Unixes and shell scripts. –  Stefan Lasiewski Jun 1 '10 at 19:46

I find that in my OS 10.6.5 the bash settings are in "/etc/bashrc". I think this is the toplevel specifications for shell.

However, you need a root account to modify it. The local per-user specifications "~/.bashrc" should start with the following snippet, to read and load the system-level bash settings:

if [ -r /etc/bashrc ]; then
    . /etc/bashrc 

I normally add aliases in the system level bashrc so that all users can access them as well. Unless they don't want to use your shortcuts and aliases.

Good luck!

share|improve this answer
/etc/profile (run by login shells) is a global bash startup script that applies to all users and provides default behaviors for login shells. It in turn runs /etc/bashrc, which contains customizations that apply to both login and non-login shells. Similarly, individual users should create a ~/.bash_profile file that runs ~/.bashrc, which is where most customizations should be, and ~/.bashrc should run /etc/bashrc to inherit default behaviors for non-login shells. –  Chris Page Aug 21 '11 at 7:25

Use the .profile file to add anything that you would add to a linux .bashrc file.

For example

alias t='/Users/<username>/.todo/todo.sh'
alias punch='python /Users/<username>/.todo/Punch.py'
alias clock='cat </dev/tcp/time.nist.gov/13'
alias sudotext="sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit" 
share|improve this answer
I recommend you use ~/.bash_profile (instead of ~/.profile) unless you're certain you want your customizations to take effect in other shells and that they're compatible. –  Chris Page Aug 21 '11 at 7:27

protected by Diago Nov 26 '10 at 8:35

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.