Posted: . At: 8:15 PM. This was 4 years ago. Post ID: 14378
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to get Mac OS to read the .bashrc file on every login.


By default, Macintosh OSX does not read the .bashrc file when you login to the operating system. But it does read the .bash_profile script if it does exist. Therefore, create the .bash_profile in your home directory and put this in it.

if [ -s ~/.bashrc ]; then source ~/.bashrc; fi

Then the .bashrc file will be read and used when you login and open a terminal window. This allows the usage of custom PS1 and other useful things like aliases. This is better than typing source ~/.bashrc every time you wish to use it.

Some very useful bash shell tips for beginners.

https://www.securitronlinux.com/lc/ShellIntro.pdf.

Advanced Linux documentation that could also be applicable to Macintosh OSX.

https://www.securitronlinux.com/lc/rute/.

The default /etc/bashrc file for Mac OSX.

jason@. PWD: ~. -bash. 3.2.57. 14 $> cat /etc/bashrc
# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
   return
fi
 
PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
 
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"

There is not much in it at all.

The /etc/bashrc_Apple_Terminal file is more comprehensive. This is good to look at, and could yield some ideas for bash scripting.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.