How can I hide username and computer in terminal command prompt?

In Terminal it says

Last login: Mon Jan 13 00:00:14 on ttys000
Whatever:~ UserName$ 

Is it possible to show just the current folder and $ sign?

  • 1
    What do you mean by show current folder? The current folder is already shown after the :. BTW: I've changed the computer name in System Preferences -> Sharing to MBP. Now my login prompt is very short: mbp:~ matt$
    – gentmatt
    Commented Dec 29, 2011 at 7:27

9 Answers 9


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.


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.

If you are NOT using BASH but ZSH, do the following:

(1) nano ~/.zshrc,
(2) add this line at the end of the file export PS1="\$ ",
(3) save the file, ~/.zshrc,
(4) source the zshrc to apply the change with source ~/.zshrc.
(5) You should be good at this point!

  • If you are not using bash but zsh, do the following: (1) nano ~/.zshrc, (2) add this line at the end of the file export PS1="\$ ", (3) save the file, ~/.zshrc, (4) source the zshrc to apply the change with source ~/.zshrc Commented Jul 11, 2023 at 21:52
  • To check which shell you are using, you can use the following command: echo $SHELL Commented Jul 17, 2023 at 19:24

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

  • This is the best for temporary solutions.
    – Tarik
    Commented Mar 20, 2017 at 6:38
  • What is the "\W" supposed to do? For me it just leaves a literal "\W" before the dollar sign
    – Tom
    Commented Jan 21, 2022 at 10:59
  • 5
    @Tom the \W is supposed to be working directory path. I think it should actually be lowercase though. However, if you are using the default Mac terminal, you aren't using bash, you are using zsh. try this: export PS1="%~ $ " Commented Feb 9, 2022 at 20:58
echo "export PS1='$ '" >> ~/.bash_profile
. ~/.bash_profile

This will leave just $ as a prompt. If you want to restore the old prompt, you will need to edit .bash_profile to remove that "export ..." line.

  • This worked like a charm in bash shell in CentOS 7 Commented Apr 9, 2019 at 12:45

Check out this tutorial on how to change your bash prompt. A very short version (only username and no current path): PS1="\u$ "

Result: myusername$ cat something.log

  • It works, now the problem is it will not save the new bash prompt. It will show the old one after i shut down my mac. Why?
    – DzulFriday
    Commented May 15, 2012 at 2:07
  • 2
    Did you put the variable in the following file: /Users/<yourusername>/.bash_profile?
    – dertkw
    Commented May 15, 2012 at 15:34

Edit ~/.bash_profile to save your changes to prompt.

nano ~/.bash_profile

At the end, add your changes.

# Change prompt
export PS1="\W \$ "

Exit, save changes. Hit enter to confirm the file name. Run source to see the change.

source ~/.bash_profile
  • Thanks, this worked nicely for me, using OSX 10.12 Sierra. Commented Sep 9, 2017 at 11:39
  • 1
    Why use sudo?
    – dan
    Commented Feb 19, 2019 at 12:21
  • Thanks for putting the space after the dollar sign!
    – brasofilo
    Commented May 17, 2021 at 1:57

Create/Edit your .bash_profile file or your root:

sudo vim ~/.bash_profile

and add this line

export PS1="\W$: "

The space will give you some breathing space in command prompt. After this modification your command prompt will looks like this:


Set DEFAULT_USER in ~/.zshrc file to your regular username. You can get your exact username value by executing whoami in the terminal. Something like this:

export DEFAULT_USER=username

export PS1="[\033[01;32m]\W \$ [\033[00m]"

\W will give you the current folder (\w to include the path too). The brackets set the color codes. So this puts the current folder in green, and then resets the color to white after the prompt.


Mine is: PS1="\W[\033[32m]\$(parse_git_branch)[\033[00m] $ "

  • We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.
    – Tetsujin
    Commented Sep 30, 2016 at 16:15
  • Delete, i don't care i was only trying to help!
    – Carlos
    Commented Oct 1, 2016 at 17:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .