As a developer or DevOp, you're likely to spend a lot of time in the Terminal, and you've probably already customized its appearance to suit you, but what about the prompt name?
The text that appears before the $ sign is the Terminal prompt name. This, by default, is set to.
HOST_NAME:USER_NAME CURRENT_DIRECTORY $
This can take up a lot of valuable real estate on each line of the Terminal, depending on what you've named your computer. To change the default prompt, you'll need to make a change to your
Open up a new Terminal window and type the following command to ensure we're in the home directory
ls -la to show the contents of your Home directory and check if a
If it does not exists, go ahead and create one with the command
Changing your Terminal prompt
Edit '.bash_profile' with your default or favorite text editor, in my case it's Vim, with the following command
i (insert) and enter the following line
export PS1="\u$ "
and save by tapping
esc key and type in
:wq,(FYI: this is specific to the Vim editor). The
\u flag sets the prompt to your username (in my case, Abayomi). Remember to keep a space after the
$ symbol to make things easier to read in practice.
Quit Terminal and relaunch to see your new prompt in action.
A little extra
With a little extra customization, my line looks like the following
export PS1="\u ~ >> "
and I ended uo with the following prompt
More Options for customizing the prompt
The following are a few common flags you can use to customize your Terminal prompt:
\d – Current date
\t – Current time
\h – Hostname
# – Command number
\u – User name
There are several options for customizing your Terminal prompt including custom strings, timestamps colors and even emoji