Up until recently, Bash was the default shell used in macOS. If you?re still using an account under Bash, here?s a quick how-to manipulate your .bash_profile file.
Create .bash_profile
To create the bash_profile, proceed with the following steps:
- Open the terminal.
- Move the home directory using the following command: cd ~/
- Use the touch command to create the bash_profile as follows:touch .bash_profile
Edit .bash_profile
- To edit the .bash_profile inside the terminal, either use vim or vi as follows: vi ~/.bash_profile
- If the bash_profile is large, then it becomes difficult to edit in the terminal itself. So we can use the TextEdit to edit bash_profile in such cases. Use the following steps in that case:
a. Open a plain text editor i.e. TextEdit.
b. Press command + o to open the file.
c. Move to your home directory.
d. There might be chances that your bash_profile is hidden in the home directory and you will not be able to see that file. Press Command + Shift + . to see the hidden file
e. Select .bash_profile, fix the problem and save it accordingly.
3. Alternatively, you can use the following simple one line to open and edit the bash_profile:open -a TextEdit.app ~/.bash_profile
Delete .bash_profile
- To delete bash_profile, go to the finder app in macOS.
- 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.
- Select the bash_profile and press Command + Delete to delete the file.