In terminal, modify the text that comes before $

In terminal I can always see which path I'm in:

macbook-romeo:School romeovs$ echo "example command"

which I find quite useful. Yet there is a lot of unnecessary stuff here too: macbook-romeo is not useful since I'm always on my macbook (duh). Then again romeovs is quite useful (this is my user name).

Is there a wan to edit what is shown here? e.g.

22:50 - School - Romeo$ echo "example"

where 22:50 is the current time? (This is just an example of course, I won't be needing the time, I'd use like the text to be a bit more minimalistic).


This OSX Daily article has some detailed instructions on how to do. In short you need to modify your ~/.bash_profile file and modify the PS1 variable.

Below is a list of possible variables you can have displayed:

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

You need to modify the .bashrc file found in your home directory.

Open terminal and do the following:

  • cd ~
  • touch .bashrc
  • open .bashrc

Add the following line at the end of your .bashrc file

export PS1='\t - \W - \u\$ '

  • Save the file and close your editor
  • Go back to the terminal and enter the following command:

    source .bashrc

Boom! You should now have your desired prompt! (If desired prompt was your given example)