Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!


Click here to return to the '10.5: Fix the sudo shell prompt' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
10.5: Fix the sudo shell prompt
Authored by: mjb on Wed, Mar 19 2008 at 1:41PM PDT
Unix convention in shell prompts is that the trailing character '$' is used for non-root users, and '#' for root (essentially).

[ Reply to This | # ]
10.5: Fix the sudo shell prompt
Authored by: corienti on Wed, Mar 19 2008 at 5:58PM PDT
Yes, it certainly has. Very long standing custom.

However in these modern times, I always use a colour prompt, and have it so the username comes up in red if root, and another colour if not root.
I find the red is far more visible and noticeable than the #.


[ Reply to This | # ]
10.5: Fix the sudo shell prompt
Authored by: corienti on Wed, Mar 19 2008 at 6:02PM PDT
For what it's worth, this is what I use. Customise colours to preference.
(note colours range from 31 to 36, and 01 and 00 indicate bold/nonbold.


if [ "${USER}" = "root" ]; then
USER_COL="01;31"; PATH_COL="01;33"
else
USER_COL="01;33"; PATH_COL="01;32"
fi
HOST_COL="01;37"
export PS1="\n\[\e[${USER_COL}m\]\u @ \[\e[${HOST_COL}m\]\h > \[\e[${PATH_COL}m\]\w/\[\e[0;38m\]\n-> "
unset HOST_COL PATH_COL USER_COL



[ Reply to This | # ]
10.5: Fix the sudo shell prompt
Authored by: mjb on Wed, Mar 19 2008 at 7:37PM PDT
My apologies, while you are correct, I was referring to the $ in the example SUDO_PS1 given. :)

[ Reply to This | # ]
The prompt shown does that
Authored by: lincd0 on Thu, Mar 20 2008 at 8:16AM PDT
Try it.

[ Reply to This | # ]
The prompt shown does that
Authored by: mjb on Thu, Mar 20 2008 at 2:53PM PDT
Don't have to, just realised I forgot about \$. I'll shut up now. :)

[ Reply to This | # ]