Edit the Terminal Prompt name on macOS

Ajay Karwal
May 14, 2018 · 2 min read

As a developer you’re likely to spend a lot of time in the Terminal and may have already customised the appearance of it to suit you, but what about the prompt name?

The Terminal prompt name is the text that appears before the $ sign. By default this is set to

HOST_NAME:USER_NAME CURRENT_DIRECTORY $

Depending on what you’ve named your computer, this can take up a lot of valuable real-estate on each line of the Terminal. In order to change this default prompt you will need to make a change to your .bash_profile file.

Open up a new Terminal window and type the command

$ cd ~/

This will ensure you’re in your User Home directory.

Type ls -la to show the contents of your Home directory and check if a .bash_profile exists.

If it does not exists, you can create one with the command

$ touch .bash_profile

Changing your Terminal prompt

To edit the .bash_profile in your default text editor (TextEdit) use the command

$ open -e .bash_profile

If this is the first time you’re editing this file, it should be empty. Add this line to the file and save.

$ export PS1="\u$ "

The \u flag sets the prompt to your User name (in my case, Ajay). 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.

Options for customising the prompt

Here are a few common flags you can use to customize your Terminal prompt:

  • \d – Current date
  • \t – Current time
  • \h – Host name
  • \# – Command number
  • \u – User name
  • \W – Current working directory (ie: Desktop/)
  • \w – Current working directory with full path (ie: /Users/Admin/Desktop/)

Going further

There are several options for customising your Terminal prompt including custom strings, timestamps colours and even emoji 👉.


More information can be found on OSX Daily.

Ajay Karwal

Written by

Thoughts on Design, Development and Technology

More From Medium

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade