How To Edit .bash_profile on MacOSX?

As a Unix based operating system, MacOSX also provides the bash terminal and related configuration files like .bash_profile . The .bash_profile file is a hidden file that is used to configure the current user bash profile and attributes. The .bash_profile file contains the startup configuration and preferences during usage of the bash terminal and environment.

List .bash_profile File

There are different ways to list the .bash_profile file but the most basic and easy way is using the bash terminal and the ls -al command. The ls command lists the files and folders where -al options enable to list hidden files and folders.

$ ls -al

Create .bash_profile File

If the .bash_profile file does not exist or is deleted creating it is very easy. The .bash_profile file can be created by using the touch command like below.

$ touch ~/.bash_profile

Alternatively, text editors can be used to create .bash_profile file like below. In the following example, we use the nano text editor.

$ nano .bash_profile

Open/Edit .bash_profile File

The .bash_profile file can be opened by using command line text editors or GUI text editors. The nano command line text editor can be used to open and edit .bash_profile.

$ nano ~/.bash_profile

Alternatively, the GUI-based text editor of the MacOSX can be used with the following command.

$ open -a ~/.bash_profile

Delete .bash_profile File

Even the .bash_profile file contains a lot of useful configuration and settings we may require to delete it. The .bash_profile file can be deleted easily with the rm command via command-line interface.

$ rm .bash_profile

Leave a Comment