The Computer Oracle

Mac OS X .bashrc not working

Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: City Beneath the Waves Looping

--

Chapters
00:00 Question
00:25 Accepted answer (Score 145)
00:56 Answer 2 (Score 111)
01:55 Answer 3 (Score 14)
02:18 Answer 4 (Score 9)
02:46 Thank you

--

Full question
https://superuser.com/questions/244964/m...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#macos #bash #bashrc

#avk47



ACCEPTED ANSWER

Score 149


In OSX, .bash_profile is used instead of .bashrc.

And yes, the .bash_profile file should be located in /Users/YourName/
(In other words, ~/.bash_profile)

For example, /Users/Aaron/.bash_profile




ANSWER 2

Score 117


.[bash_]profile and .bashrc can be used on both OS X and Linux. The former is loaded when the shell is a login shell; the latter when it is not. The real difference is that Linux runs a login shell when the user logs into a graphical session, and then, when you open a terminal application, those shells are non-login shells; whereas OS X does not run a shell upon graphical login, and when you run a shell from Terminal.app, that is a login shell.

If you want your aliases to work in both login and non-login shells (and you usually do), you should put them in .bashrc and source .bashrc in your .bash_profile, with a line like this:

[ -r ~/.bashrc ] && source ~/.bashrc

This applies to any system using bash.




ANSWER 3

Score 10


Or create a sym link called .bash_profile pointed at your .bashrc

ln -s .bashrc .bash_profile



ANSWER 4

Score 9


I tried using the solution to update .bash_profile and .bashrc but that did not work because MacOS >= 10.15 (Catalina) is using zsh as default.

So:

  • create a new file, ~/.zprofile, add aliases there.
  • use command source ~/.zprofile to execute in same shell or just open a new terminal.

and your changes should be permament.