Bug 144620

Summary: terminal features
Product: [openSUSE] SUSE Linux 10.1 Reporter: Forgotten User 7L3tOtZIov <forgotten_7L3tOtZIov>
Component: UsabilityAssignee: Michael Loeffler <michl>
Status: RESOLVED FIXED QA Contact: Siegfried Olschner <siegfried.olschner>
Severity: Enhancement    
Priority: P5 - None CC: andreas.hanke, forgotten_3gCYeee-ni, hhetter, mrmazda, silviu_marin-caea, suse-beta, werner
Version: Beta 3   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: My personal ~/lib/share/sh.lib a library which uses terminfo and tput

Description Forgotten User 7L3tOtZIov 2006-01-21 15:48:11 UTC
Have a colour (red) for root as a standard. This will be more clear for the average user then only the difference in the prompt.

Having a (semi) transparent theme would alos be nice.
Comment 1 Christian Boltz 2006-01-21 18:31:37 UTC
What about http://www.cboltz.de/en/linux/bashprompt/ ?  ;-)
Comment 2 Forgotten User 7L3tOtZIov 2006-01-21 18:54:25 UTC
That or something else from the bash prompt howto. Having root with a red background could indeed already be a good idea. As long as the difference is much more clear as it is now.
http://www.gilesorr.com/bashprompt/prompts/index.html has some nice ones as well.

Others could be in company colors. Green for SUSE red for Novell. :-)
Comment 3 Siegfried Olschner 2006-01-23 15:30:25 UTC
Hmm, the idea with fontcolor is interesting. We have a color-blind developer here, I will ask for his mind.  


Comment 4 Christian Boltz 2006-02-07 19:27:50 UTC
beta3 is still black and white.

Any news about this? ;-)
Comment 5 Siegfried Olschner 2006-02-08 14:32:56 UTC
No news about this.
Everyone is snowed under with works.

Marco, Holger what do you think about such a feature?


Comment 6 Holger Hetterich 2006-02-08 15:08:52 UTC
Being color-blind doesn't mean you can't see any colors, so it's no problem for me to have colored prompts. :)

It's a good idea, you immediately see that root is working here.

I would just color the font itself, and not the background of the characters. The "Inverted" style is IMHO really not nice.


Comment 7 Forgotten User 7L3tOtZIov 2006-02-08 15:25:24 UTC
Yes. Just the font itself. Green for standard user. Red for root. Adding something like the following will make it easier for people to edit the colours:

#Colors
BLACK="\[\033[0;30m\]"
GREY="\[\033[1;30m\]"
BLUE="\[\033[0;34m\]"
LBLUE="\[\033[1;34m\]"
GREEN="\[\033[0;32m\]"
LGREEN="\[\033[1;32m\]"
CYAN="\[\033[0;36m\]"
LCYAN="\[\033[1;36m\]"
RED="\[\033[0;31m\]"
LRED="\[\033[1;31m\]"
PURPLE="\[\033[0;35m\]"
LPURPLE="\[\033[1;35m\]"
BROWN="\[\033[0;33m\]"
YELLOW="\[\033[1;33m\]"
LGREY="\[\033[0;37m\]"
WHITE="\[\033[1;37m\]"
NO_COLOUR="\[\033[0m\]"
# Prompt
PS1="$GREEN\u@\h : $NO_COLOUR"

For Root obviously $RED instead of $GREEN
Comment 8 Siegfried Olschner 2006-02-13 10:44:53 UTC
Michl, do you need such a feature in the SL?
Then you should create a section in FATE 
(and eventually request a Usability-Report ;-)
Comment 9 Forgotten User 7L3tOtZIov 2006-03-20 22:57:06 UTC
pinging
Comment 10 Silviu Marin-Caea 2006-04-11 16:08:45 UTC
Careful not to over do it.  The prompt should not be too noisy.  For example I'm using the regular prompt but with a red # sign.

echo $PS1
\h:\w \[\e[31m#\[\e[0m\]\]
Comment 11 Forgotten User 7L3tOtZIov 2006-06-07 04:22:07 UTC
It should indeed not be too noisy.

For root: PS1="\h:\w \[\e[31m#\[\e[0m\]\] "
For user: PS1="\h:\w \[\e[1;32m:\[\e[0m\]\] "

So just colours for respectivaly the '#' for root and the ':' for a user.
It looks less agressive then having the whole prompt in Green/Red. It also still has the difference between # and : for root and user.
Comment 12 Forgotten User 7L3tOtZIov 2006-07-17 16:56:47 UTC
No change in 10.2 Alpha 2
Comment 13 Forgotten User 7L3tOtZIov 2006-09-09 12:48:42 UTC
Ni change in Alpha 4.
Comment 14 Michael Loeffler 2006-09-26 10:46:41 UTC
Sorry for the delay here. I added Werner who is the bash maintainer for his opinion on that.
Comment 15 Dr. Werner Fink 2006-09-26 10:57:54 UTC
Created attachment 99614 [details]
My personal ~/lib/share/sh.lib a library which uses terminfo and tput

... with this library we do not depend on escape
sequences but use terminfo capabilities. My
root prompt looks like this

PS1="\\[$(tput bold; tput setaf 1)\\]\\h:\\W \\$ \\[$(tput sgr0)\\]"
Comment 16 Dr. Werner Fink 2006-09-26 11:03:37 UTC
IMHO colo(u)red prompts is a users feature and he/she should handle this.
Nevertheless we could add the attachment to an appropiate location.
Any suggesstions for the name and location in the system?
Comment 17 Forgotten User 7L3tOtZIov 2006-09-26 15:26:03 UTC
I could argue that everything in KDE and GNOME is also user features. Also the alias for `ls` is something that could fit under the user features, It is not as if we will override user settings if they want to change it, just that it is clear what the difference is between User and Root and that in a subtle way.
Especially for the user who does not use CLI often enough to know if or how to change these colors himself.

If it would just be in bash, that would already be great, because people who use something else will surely be able to change it and this is a warning for people who are not that confident in CLI.

So I would go for /etc/bash.bashrc. Look at comment 11 for a subtle example.

Or else for /etc/skel/.bashrc or or /etc/profile or any (or some) of the /etc/profile.d/* files, I see that there are already some SUSE specific changes in /etc/profile, so this customisation should fit right in.
Comment 18 Dr. Werner Fink 2006-09-26 16:39:24 UTC
The problem is: you will get some customers and users which will complain
about such a change.  I'm remembering on such complains about a few changes
in /etc/bash.bashrc or /etc/profile and addons like /etc/profile.d/complete.bash
One reason to avoid colored prompts which _is_ visible to the users.
Comment 19 Forgotten User 7L3tOtZIov 2006-09-26 20:01:49 UTC
It _is_ indeed visible. That is the whole point. :-)

I am sure that any chane will bring about complaints. For each change you will find people who will complain for whatever reason.The question you have to ask wether it is an improvement or not. I think it is. Just like you have different backgrounds in KDE for root and a different one for a user.

Or the difference when opening Konsole (I think) in a different colour when opening as root.

I know it saved me some stupid mistakes by seeing clearly that I was root and I would help preventing thse mistakes with others as well. All people I have met and asked do have edited the prompt to make it clear that they are root and almost all used a colour to do so.

Comment 20 Forgotten User 7L3tOtZIov 2006-10-28 11:56:35 UTC
Beta 1 still does not contain this simple addition. KDE and GNOME are completely reworked and styled to SUSE norms and clearly have a difference between root and user. Why not with CLI?

Please look at Comment 11, where an example of a very subtle change is proposed.
Comment 21 Forgotten User 7L3tOtZIov 2006-11-11 02:59:18 UTC
Beta 2 still no colour. Even an ls gives colour and that is also not default. So please add this. Even getting a baby is faster then adding something this easy and usefull.
Comment 22 Forgotten User 7L3tOtZIov 2006-11-23 18:06:55 UTC
Still nothing. Are we aiting for the 1 year celebration of this ticket?
Comment 24 Forgotten User 7L3tOtZIov 2007-03-06 19:41:26 UTC
OK. Can we have it for 10.3? This is NOT rocket science. All it does is to make it clear wether you are running as root or as user, by using colour. This can be compared to linking colours to `ls`.

The reason that some people might complain is not valid as long as you do other changes as well. Either you do change things for the better, or you don't. If there is no good reason to have colours, then remove them from the 'ls' as well. 

This is now more then a year old.
Comment 25 Dr. Werner Fink 2007-03-07 10:04:54 UTC
I've added the lines

        if test "$UID" -eq 0 -a -t && type -p tput > /dev/null 2>&1 ; then
            _bred="$(tput bold 2> /dev/null; tput setaf 1 2> /dev/null)"
            _sgr0="$(tput sgr0 2> /dev/null)"
            PS1="\[$_bred\]$PS1\[$_sgr0\]"
            unset _bred _sgr0
        fi

to /etc/bash.bashrc
Comment 26 Jan Engelhardt 2007-03-22 02:13:13 UTC
Bah, someone stole my idea!

\[\e[1;30m\]\A \[\e[0;31m\]\h:$(beautify_path) \[\e[1m\]#\[\e[0m\]

(aaa_base-10.2-38.jen4 and long before)
Comment 27 Silviu Marin-Caea 2007-09-12 06:19:28 UTC
I find it very useful to have a time prompt for each line.  It provides me with a time scale of commands given.  It's most useful as root, where you give some commands then you check the system logs for effects of those.  With a time prompt, you can order cause and effect very clearly.

I have added a \t to _u in /etc/bash.bashrc in this section.

        # Other prompting for root
        _t=""
        if test "$UID" -eq 0  ; then
            _u="\t \h"
            _p=" #"
        else
            _u="\t \u@\h"

Personally I have it for all users (in the "else" branch), but, as I said it's most useful for root.  I don't expect this to be in 10.3, it's too late.  Let people express opinions and add it perhaps in the next version, if those opinions are positive.
Comment 28 Dr. Werner Fink 2007-09-12 08:47:23 UTC
Please use /etc/bash.bashrc.local for such changes.  IMHO it makes
no sence to add personal preferences to /etc/bash.bashrc
Comment 29 Forgotten User 3gCYeee-ni 2010-10-11 20:51:07 UTC
The addition of this "feature" has caused issues with all of our prior deployed login session expect scripts.  Please don't put "pretty" or "helpful for the clueless" enhancements into Enterprise Server builds in the future.
Comment 30 Felix Miata 2010-10-11 22:37:00 UTC
I agree this should be reverted. The comment 25 section could be left in with appropriate comments for those who think that this was a good idea. For me and others who use black text on white background in Konsole, a red on white prompt isn't much better than a white on white prompt.
Comment 31 Forgotten User 7L3tOtZIov 2010-10-12 09:47:01 UTC
ls produces colors. So colors are to be expected on openSUSE terminals.

And this is NOT about being "pretty" but to give the user an extra alert when he is logged in as root. 

As far as SLE goes, I am purely talking about openSUSE and have no experience with SLE, so no comment there as I also have no idea in how far that is Vanilla, i.e. no adaptions to /etc/bash.bashrc and no colours with ls.
I do understand if the people would want no adaption at all. However that should be discussed in the aproprate place and not on the openSUSE part.

I also have no idea why this would come up suddenly after several years of it being used in openSUSE without any complaints.
Comment 32 Dr. Werner Fink 2010-10-12 10:44:38 UTC
Such "helpful for the clueless" enhancement are and were part of all SLES
versions out there and only active for interactive shells. That is that a
login session using a script instead of a login shell do not use them.

Beside this not only users openSUSE but also customers of SLES products had
contribute such enhancements.  The core source part of SLES and openSUSE are
identical. After a release has happen the source tree of the specific product
will be maintained on this state.
Comment 33 Holger Hetterich 2010-10-12 11:20:12 UTC
Outing myself as one of the "clueless" then, it helps me a lot when I work in tabbed terminals while programming. it just makes my recognition of "here is the root window" a few milliseconds faster. I like it.