trouble with a tricky prompt mod.
Imported from the Apple Support Forums via the Wayback Machine 🔗
Hello genii
I am trying to change my Terminal prompt as I had it in 10.3 where the standard user would be shown in green and if dropped down to root, that would be shown in red. I like that because the red is a good visual reminder of where you are. Example:
Standard ~/Documents $
root /etc #
However, this only partly works in Leopard . I get the green username and the directory listing in the prompt alright, but when I change to root with sudo -s, it defaults to the original Leopard bash prompt of bash-3.2#
Here is my bashrc script that worked well in Panther. The colour values are highlighted.
# System-wide .bashrc file for interactive bash(1) shells.
PS1='h:w u$ '
if [ "$TERM" != 'dumb' ] && [ -n "$BASH" ] && [ -n "$PS1" ]
then
if [ "$whoami" = 'root' ]
then
PS1='[33[22;31m]u [33[22;34m]w $ [33[00m]'
else
PS1='[33[22;32m]u [33[22;34m]w $ [33[00m]'
fi
fi
# Make bash check it's window size after a process completes
shopt -s checkwinsize
Notes: both if statements have '['square brackets']' around them but they got lost in the format.
Also, lines System-wide... and Make bash check... are commented lines that got lost too.
I have been trying so many things, but frustratingly to no avail. I also made a ~ .bash_profile, with bashrc back to orig. and it behaves the same, giving me the green standard user, but fails to process root. After each change I close Terminal and re-open it as I think that is needed.
I am at this stage willing to abandon such a fancy prompt and settle for just the 'else' format as a one line unconditional, and doing so does indeed give me the user as root, but in green not red. Maybe that is the best I can hope for, - just thought maybe I'm missing something, or maybe it is Leopard!
Any thoughts?
Here is a better view of the script.
http://farm4.static.flickr.com/3192/2523920928de4b7398d5o.png
Message was edited by: roam2
14 replies
Sign in or join Beachball Help to reply.
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0