Where Is ~/.bash_rc File In MacOSX?

When working with the command-line interface in MacOSX the bash is the default shell. The bash provides the environment settings, variables about the command-line interface. The ~/.bashrc is used to set these settings, environment variables, new commands, alias, PATH information, etc. Even MacOSX has a lot of similarities to the Linux and distributions the ~/.bashrc is located under the user home directory in MacOSX it is not.

~/.bashrc File

The .bashrc file is located under the each users home directory. The home directory is expressed with the ~ sign. The bashrc file is hidden with a dot before its name. Below is the .bashrc file defualt content which makes some checks sets history file size etc.

~/.bashrc File

MacOSX ~/.bash_profile or ~/.profile

MacOSX or OS X the .bashrc file is implemented with different names. Even you can create it and set properly the MacOSX provides the ~/.bash_profile or ~/.profile files. The file changes for different MacOSX versions. So just chech which file exist with the ls command like below.

ls -l ~/.profile
-rw-r--r-- 1 ismail ismail 807 Kas  2  2020 /home/ismail/.profile

Or for the .bash_profile file.

ls -l ~/.bash_profile
ls: cannot access '/home/ismail/.bash_profile': No such file or directory

As the .bash_profile file is not exist we get an error like “No such file or directory”.

Add ~/.bashrc File In MacOSX

If you want to use the .bashrc file like Linux systems you can add it in MacOSX. Just put the following line to your ~/.bash_profile or ~/.profile file whichever exists. But do not forget to create the .bashrc file and put your content.

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

Leave a Comment