Change hostname and prompt in OS X terminal

Solution 1:

Just run this command in terminal

PS1="[\u@\h:\w]$ "

here

  • u represents username
  • h represents hostname
  • w represents current working directory

This is temporary, that means after running this command if you close the terminal again, the default prompt will appear.

If you want to set permanently, then insert below line in your .bash_profile file under your home directory:

export PS1="[\u@\h:\w]$ "