简体   繁体   中英

How do I remove the username from my mac terminal prompt?

I would like to remove my mac's username from the terminal and ideally just have the directory and $ on the line.

I've tried going into preferences and setting the shell to run command:

PS1 = "\ w \ $"; clear;

This doesn't work.

When assigning a variable, there can't be whitespace around the = sign.

Try removing it: PS1="\ w \ $"

Also, if you're using zsh on your Mac, the \w doesn't seem to work. Try using $(pwd) for the current working directory instead.

Try anyone from the below options,

Option 1:

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

OR

Option 2: This will show directory and $ as a prompt

   echo "export PS1='\W \$'" >> ~/.bash_profile
    . ~/.bash_profile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM