Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run ~/.bash_profile in mac terminal

Tags:

terminal

macos

So I'm installing some things for coding and personal usage, and I need to run this in the terminal (I'm on Mac if you didn't read the title).

~/.bash_profile

It just says permission denied, Im running OSX 10.8.4 Mountain Lion. How do I bypass this?

like image 422
Nick Wetter Avatar asked Sep 16 '13 01:09

Nick Wetter


People also ask

How do I open a bash profile on a Mac?

Go the users home directory. Check if the bash_profile is visible there or not. If not, press Command + Shift + . and bash_profile will be visible.

Where is .profile on Mac?

View an installed configuration profile On your Mac, choose Apple menu > System Preferences, then click Profiles . If you haven't installed any configuration profiles, Profiles preferences isn't available. Select a profile in the Profiles list to view information about it.

How do I open a bash profile?

###Text Editor Method: Open up Terminal and enter in open -e . bash_profile . This will open your profile in a simple text editor.

How to manage your bash_profile in macOS?

How to Manage Your .bash_profile In macOS 1 Create .bash_profile. Open the terminal. 2 Edit .bash_profile. If the bash_profile is large, then it becomes difficult to edit in the terminal itself. So we can... 3 Delete .bash_profile. To delete bash_profile, go to the finder app in macOS. Go the users home directory. Check if the... More ...

How to create a bash_profile in Linux?

To create the bash_profile, proceed with the following steps: 1 Open the terminal. 2 Move the home directory using the following command: cd ~/ 3 Use the touch command to create the bash_profile as follows: touch .bash_profile

How do I make Bash run automatically when terminal starts?

However, if you want to source it to run automatically when terminal starts instead of running it every time you open terminal, you might add . ~/.bash_profile to ~/.bashrc file. When you open a terminal, the terminal starts bash in (non-login) interactive mode, which means it will source ~/.bashrc.

How to refresh a shell profile in Linux?

Many users simply launch a new shell or open a new terminal window, but there is no need to do that, there’s a way to directly refresh the profile in use thanks to the source command. Reloading and refreshing other command line shell profiles, tcsh, fish, etc is just a matter of pointing source at the initialization script like so:


2 Answers

On MacOS: add source ~/.bash_profile to the end of ~/.zshrc. Then this profile will be in effect when you open zsh.

like image 154
zhao Avatar answered Sep 22 '22 17:09

zhao


You would never want to run that, but you may want to source it.

. ~/.bash_profile source ~/.bash_profile 

both should work. But this is an odd request, because that file should be sourced automatically when you start bash, unless you're explicitly starting it non-interactively. From the man page:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

like image 36
kojiro Avatar answered Sep 24 '22 17:09

kojiro