How to Manage Your .bash_profile In macOS

How to Manage Your .bash_profile In macOS

Image for post

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:

  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

Edit .bash_profile

  1. To edit the .bash_profile inside the terminal, either use vim or vi as follows: vi ~/.bash_profile
  2. 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

  1. To delete bash_profile, go to the finder app in macOS.
  2. Go the users home directory.
  3. Check if the bash_profile is visible there or not. If not, press Command + Shift + . and bash_profile will be visible.
  4. Select the bash_profile and press Command + Delete to delete the file.
19

No Responses

Write a response