How do I remove the hostname from the bash prompt in Terminal? [duplicate]

Change your prompt in your ~/.bashrc file. The example you asked for would be:

export PS1="\W \$"

It would result in the current folder you're in being shown plus a $ for the regular prompt and a # if you're root. Check out this guide for more examples of what you could show in your prompt.

Edit:

As per one of the comments below, you might need to source your ~/.bashrc from your ~/.bash_profile or even put this code in your ~/.bash_profile instead. You can read this article for a better explanation on which file to use.


I had a similar issue with this but did not get it working at first.

This may of been because I wasn't sudo but either way this works just as well.

  1. Open the preferences in the terminal (top right)
  2. Then go into the shell tab
  3. Then copy/paste the command export PS1="\W \$"; clear;
  4. Then restart the terminal and should work

enter image description here