Tuesday, June 30, 2009

Bash shell configuration

Further to my last post about bash, it really bugs me having to `exec bash` because my .bashrc isn't being executed when I login. After changing my shell to /bin/bash I was able to get a useful command prompt thanks to the various defaults in place and moved on. But when I run dir (no, I can't just ls -l nor ll like normal people) I get the same horizontal ls lameness, not the dir='ls -l --color' goodness that I expect.

I found this thread which showed the solution for my Ubuntu box. So I put

source ~/.bashrc

into my .bash_profile and now when I su to the account I get my environment exactly as I configured it.

Factoid: It turns out (man pages ftw) that bash's default is to ignore any.bashrc file if it is being executed as "sh", so even if /bin/sh is symlinked to /bin/bash the script won't be run as I assumed it would.