Thursday, February 26, 2009

~/.bashrc won't load in OSX terminal

While I was in my /etc/bashrc tonight setting up macports I thought of something that has always bugged me but I never really cared enough to figure out.

Why doesn't by personal bash config file (~/.bashrc) not load when I launch a terminal?

I still don't know the answer to that question, but I at least figured out a really simple hack tonight.

inside of /etc/bashrc you simply need to add the line(I added it at the end)

This will load all your personal aliased and settings right bash loads and performs the system-wide aliases and config options. If this solves all your problems, then you can go about your day and I was glad to help ^.^ But this could actually be improved upon if people care to follow along.

Depending on the contents of your ~/.bashrc file, you may need to use this line instead
. ~/.bashrc

that is, <dot><space>~/.bashrc. this executes all the commands within ~/.bashrc within the current shell process. This does not make a difference for most commands. The only only I know of is cd (change directory) which. Scripts which call the system command cd must be executed with <dot><space> in order for that change to be reflected in the shell executing the script after execution ends.

So there you go, now you can make all terminals you launch cd into your code root directory when you launch the terminal. I don't but I don't judge you ^.^

Labels: , ,


Post a Comment

Subscribe to Post Comments [Atom]

<< Home