How can i get default prompt and get rid of "sh-3.2#"?
Asked Answered
J

3

15

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

Jared answered 24/2, 2018 at 13:29 Comment(6)
It's actually root. Don't worry. Type exit and you'd be back to your actual user account. ezprompt.net and 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.Manus
I just want to get default text for it, i can't even remember what was that it just erased from my mind...Jared
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.Manus
@Manus i want to change sh-3.2# to ComputerName:CurrentDirectory User$ Edit: Changed!Jared
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.Manus
@Manus i added a comment how did i fix it, thanks for all of your effort!Jared
J
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

Jared answered 24/2, 2018 at 14:25 Comment(0)
C
35
  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
Casia answered 5/5, 2021 at 13:24 Comment(4)
This solution worked easiest for me. Did this through my IDE and selected my zsh file. For some reason it changed to bash. Thank you.Kunkel
This is correct answerChiffchaff
This is def the correct answer.Colorblind
Had to go to bash and come back to zsh to see my regular prompt -- specific to terminal with intellijBaltimore
S
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.

Stealthy answered 24/2, 2018 at 13:45 Comment(4)
PS1="\h:\W \u$" I think this is the original prompt OP hadManus
@Manus 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) \$Jared
@Manus only thing you're missing is a space PS1="\h:\W \u$ "Stealthy
@Stealthy sorry. Didn't see that. There would be a space at the end.Manus
J
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

Jared answered 24/2, 2018 at 14:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.