[macos] How to fix Terminal not loading ~/.bashrc on OS X Lion

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.

loaded bashrc

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?

This question is related to macos bash terminal osx-lion

The answer is


I have the following in my ~/.bash_profile:

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

If I had .bashrc instead of ~/.bashrc, I'd be seeing the same symptom you're seeing.


Renaming .bashrc to .profile (or soft-linking the latter to the former) should also do the trick. See here.


Examples related to macos

Problems with installation of Google App Engine SDK for php in OS X dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac Could not install packages due to an EnvironmentError: [Errno 13] How do I install Java on Mac OSX allowing version switching? Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) How can I install a previous version of Python 3 in macOS using homebrew? Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

Examples related to bash

Comparing a variable with a string python not working when redirecting from bash script Zipping a file in bash fails How do I prevent Conda from activating the base environment by default? Get first line of a shell command's output Fixing a systemd service 203/EXEC failure (no such file or directory) /bin/sh: apt-get: not found VSCode Change Default Terminal Run bash command on jenkins pipeline How to check if the docker engine and a docker container are running? How to switch Python versions in Terminal?

Examples related to terminal

Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave Flutter command not found VSCode Change Default Terminal How to switch Python versions in Terminal? How to open the terminal in Atom? Color theme for VS Code integrated terminal How to edit a text file in my terminal How to open google chrome from terminal? Switch between python 2.7 and python 3.5 on Mac OS X

Examples related to osx-lion

commands not found on zsh Why does cURL return error "(23) Failed writing body"? What is the "Illegal Instruction: 4" error and why does "-mmacosx-version-min=10.x" fix it? Location of the mongodb database on mac How do I timestamp every ping result? How to run iPhone emulator WITHOUT starting Xcode? configure: error: C compiler cannot create executables sudo: port: command not found Disable elastic scrolling in Safari Completely uninstall PostgreSQL 9.0.4 from Mac OSX Lion?