Whenever I open a new tab in Terminal using Cmd + T, it opens bash in the same directory, as the previous tab. This works fine when I'm in the ~
directory, but if I'm anywhere else, I get an error loading .bashrc
Last login: Sat Oct 15 21:10:00 on ttys002 -bash: .bashrc: No such file or directory Jakub-Arnolds-MacBook-Pro:projects darth$
It looks like .bashrc
is loaded via relative and not absolute path, because if I do source ~/.bashrc
, everything works smoothly.
I think this is a OS X Lion related problem, because before the upgrade from Snow Leopard, I didn't have the same issue. But that might be caused by Terminal always opening at ~
, I don't remember if it tried to open the same directory.
However the question remains the same, how can I make Terminal load ~/.bashrc
via absolute path, and not relative?
bashrc file typically lives at ~/. bashrc . For my Mac for example that is /home/lcollado/. bashrc .
On macOS /etc/profile sets the default PATH with the path_helper tool and then source s /etc/bashrc which (you guessed) would be the central file for all users that is executed for non-login interactive shells. For macOS Terminal.
Terminal opens a login shell. This means, ~/.bash_profile
will get executed, ~/.bashrc
not.
The solution on most systems is to "require" the ~/.bashrc
in the ~/.bash_profile
: just put this snippet in your ~/.bash_profile
:
[[ -s ~/.bashrc ]] && source ~/.bashrc
Renaming .bashrc
to .profile
(or soft-linking the latter to the former) should also do the trick. See here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With