How to edit your .bash_profile file
When I first opened Terminal on my Mac, the prompt was really long. It contained the full name of my Mac, which for some reason I had allowed to be insanely … not great. So I wanted to change the way my prompt looked.
To do this, I edited my user profile on the system.
That profile is controlled by a user’s .bash_profile file. I found a helpful article titled How to Customize your Terminal Prompt and followed the instructions. The article shows you many options.
You start with this (at the command prompt):
You could use nano to open any other text file (just use the filename and path, if necessary, after the word nano).
Anyway, you press Return and thereby go into a simple text editor. If there’s nothing in your .bash_profile file yet, you’ll see your cursor blinking at the top left corner of a blank area. Above that is a bar that says GNU nano and the version number. At the bottom of the screen are some commands, but you might not realize that WriteOut actually means Save (duh).
DO NOT DELETE anything that is already in your .bash_profile file. Move the cursor down below that stuff, on a new line. This is how I changed my command prompt:
export PS1=”\u \W $ “ [NOTE: This is case sensitive.]
So this is my crib sheet for nano on Mac OS:
Save a file: Control-o [press Return to accept the filename given*]
Exit the file and program: Control-x
That’s all, just two commands.
*After you save, it asks if you want to save that file. I guess it wants you to make sure you’re editing the file that you intended. Press Return at that point, or your file will not be saved.