11

Recently, i downloaded brew and npm to my reinstalled macOS, and now i noticed, when i write "su" command and write my password, i am getting this:

su.png

My problem is, I want to get old su prompt, how can i get it?

I can't even remember what was it saying when i type su command. I don't know what to do, so i couldn't try anything.

I've searched and all i found is "this is root, it is ok". I can get it is root but i want to get old look. When i type "whoami" it says root.

Thanks for all help!

Sorry for all mistakes in my question

  • 1
    It's actually root. Don't worry. Type `exit` and you'd be back to your actual user account. http://ezprompt.net and https://wiki.archlinux.org/index.php/Bash/Prompt_customization would help you a lot if you still want to customize the prompt. Basically what's happening is that the prompt for root account is different than the prompt for your user account. It can be customized though. Refer the links above for more help or info. – GLaDOS Feb 24 '18 at 13:47
  • I just want to get default text for it, i can't even remember what was that it just erased from my mind... –  Feb 24 '18 at 13:54
  • please read the archwiki link. Be willing to learn. I don't get what you want. Either change the `.bashrc` in `/root/` or type `exit` or `Ctrl-D` and you'd be back to your user account which has the old prompt. – GLaDOS Feb 24 '18 at 14:25
  • @GLaDOS i want to change sh-3.2# to ComputerName:CurrentDirectory User$ Edit: Changed! –  Feb 24 '18 at 14:27
  • Type `PS1="\h:\W \u$ "` and press enter. It'd show `root` instead of `oguzhanvarsak` as you are in root. This is temporary though. Follow /u/man0v 's advice to make it persistent. Its not recommended to stay in root all the time. Don't run downloaded scripts as root if you don't trust the source. – GLaDOS Feb 24 '18 at 14:33
  • @GLaDOS i added a comment how did i fix it, thanks for all of your effort! –  Feb 24 '18 at 14:39

3 Answers3

25
  1. Go to Preferences > Tools > Terminal
  2. click on the folder icon in Shell path
  3. Select your preferred, bash, zsh ect.
  4. Close and reopen terminal
Haider Malik
  • 1,581
  • 1
  • 20
  • 23
2

To set up a prompt you need to set the PS1 variable in your root .bashrc. To use the same one as your current user's your can print it

echo $PS1

and then once you su in you can put it in your .bashrc:

PS1="\h:\W \u$ "

That way round, next time you login as root it'll be picked up.

Thanks to Glados for pinpointing the default PS1 on mac.

man0v
  • 654
  • 3
  • 13
  • `PS1="\h:\W \u$"` I think this is the original prompt OP had – GLaDOS Feb 24 '18 at 13:53
  • @GLaDOS when i type echo $PS1 it still gives me \h:\W \u$ if i am on$. but when i type it with #, it gives something else like this: \s- (enter) (tab) \$ –  Feb 24 '18 at 13:57
  • @GLaDOS only thing you're missing is a space `PS1="\h:\W \u$ "` – man0v Feb 24 '18 at 13:59
  • @man0v sorry. Didn't see that. There would be a space at the end. – GLaDOS Feb 24 '18 at 14:21
1

Ok i changed it to my wish finally!

Step 0:

su -> password

Step 1:

nano .bash_profile

Step 2:

export PS1="\u@\h\w $ "

Step 3:

CTRL - O -> Return -> CTRL - X

Result.png