Where is the .profile file on mac?

Question:

I have a MacBook Pro 13` inch (without touch bar) and it is running mac os sierra. I have installed Xcode, command line tools and homebrew. Now I want to install python 3 and make it a default interpreter when calling it from the terminal. I have found this guide http://docs.python-guide.org/en/latest/starting/install3/osx/ and I get confused when they say I should add the path to the ~./profile but I don’t know where to find the file. Can somebody help with step by step guide on how to create it if it not there?

Thanks

Asked By: Andile

||

Answers:

The file you are looking for depends on your shell, so if you are using bash, which is the default shell on Mac systems, it will be either ~/.bash_profile, or ~/.bashrc depending on whether you are in a login shell or non-login shell respectively.

Mac Terminal runs a login shell every time a new terminal window is open, and it calls .bash_profile, so you should use ~/.bash_profile.

Answered By: Mansuro

I felt to add something here that ate a lot of my time when I had a similar issue.

Many a times the .profile or the .bash_profile (in case of bash shell) is not present. This is typically when you have freshly installed the OS or when you’re on a new machine. This gets confusing as one may think if the installation wasn’t correct etc. Nothing to worry about. If you don’t find these files then simply create it new using vi or whatever means (GUI) and you’re good to go. Having a shell doesn’t mean you have these files too and you have to create it yourself if you’re the first one to use it.

Answered By: Saurabh Patil

On Mac, zsh is the default shell. You can check this by running

echo $SHELL

If so, you can check for ~/.zshrc if not you can create one and add required commands, alias which need to run during the terminal startup.

Then you can run

source ~/.zshrc

This will be executed every time the terminal is opened.

Answered By: user2216322

It could be that you are not running bash (rather an extended version like zsh, ksh, etc)

If you are running bash shell, then you should be able to see ~/.bash_profile, or ~/.bashrc or ~/.profile.

Incase of zsh shell, you would see .zprofile or .zshrc

You can check what shell you have by echo $SHELL

Answered By: Shree

After you install "Brew", there is a prompt in the terminal that says: "Next Steps:"

Follow those steps!

Answered By: James