:: Re: [DNG] New behaviour under Devua…
Inizio della pagina
Delete this message
Reply to this message
Autore: Didier Kryn
Data:  
To: dng
Oggetto: Re: [DNG] New behaviour under Devuan.
Le 23/09/2017 à 15:50, Miroslav Rovis a écrit :
> On 170923-19:01+1000, Erik Christiansen wrote:
>> On 23.09.17 10:15, Arnt Karlsen wrote:
>>> ..I still miss and prefer the S.u.S.E.-5.2 way, root had a
>>> nice red background color in xterms, fairly hard to miss.
>> If the '#' and "root@hostname" escape the attention of a person
>> entrusted with root privileges, then why not make the root prompt bright red:
>>
>> root@ratatosk:/home/erik# export PS1="\[\033[1;31m\]\u@\h:\W\$ \[\033[0;0m\]"
> Useful. But in which file do you stick it, you didn't say? ~/.bashrc ?
>
>> OK, that reverted the '#' to '$', presumably because I'd su-ed, rather
>> than logged in as root. (\$ => '#' for uid==0, else '$')
>>
>> As all my xterms are yellow on darkslategrey, one bright red prompt
>> cannot be missed, even from the other side of the room.
> However, the issue is somebody, origianally in Debian of course, decided colors
> were distractful for users, and the default is no color in the prompt.
>
> Find this wrong notion engraved, (lets put it mildly), in the comment at line
> 45 of:
>
> /etc/skel/.bashrc
>
> and it reads (the subject of the sentece added by me):
> [color] turned
> # off by default to not distract the user: the focus in a terminal window
> # should be on the output of commands, not on the prompt
>
> It isn't so in my system, because I detected that and changed it. And root is
> still not color'ed, but normal user is now green, which is enough for me to
> know which terminal windows in my X are root. Simply: "root@gdOv:/home/mr#"
> without color, is not enough. But when user "mr@gdOv:~$" is in color green,
> which happens because I uncommented where it reads (now the first part of that
> comment, along with the overlapping part) in the /etc/skel/.bashrc:
>
> # uncomment for a colored prompt, if the terminal has the capability; turned
> # off by default to not distract the user:
>
> ...So, when the user "mr@gdOv:~$" is in color green, I can't anymore miss where
> I'm root instead.
>
> I think in most of people's boxen the default is set, i.e. no color prompt,
> which has these lines from /etc/skel/.bashrc commented out (but I don't
> remember with certainty, and also read on if it's another change that does it
> in fact):
>
> if [ -n "$force_color_prompt" ]; then
>      if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
>          # We have color support; assume it's compliant with Ecma-48
>          # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
>          # a case would tend to support setf rather than setaf.)
>          color_prompt=yes
>      else
>          color_prompt=
>      fi
> fi

>
> And they read like the above in mine /etc/skel/.bashrc .
>
> Attaching the /etc/skel/.bashrc as _bashrc.gz . It likely won't get to the
> Lurker archives, attachments are not allowed in, other than text attachments,
> but it will be available in the www.mail-archives.com, right after the message
> to which I'm replying:
> Re: [DNG] New behaviour under Devuan.
> https://www.mail-archive.com/dng@lists.dyne.org/msg17863.html
>
> if I'm not mistaken.
>
> Interested reader can compare my /etc/skel/.bashrc if they have missing color
> in their terminals in Xorg (open the attachment where available)):
>
> _bashrc.gz
>
> However, it might be another bit of code, thanks to which I have color'ed
> terminal prompt as regular user... Looking up this diff:
>
> mr@gdOv:~$ diff /etc/skel/.bashrc .bashrc
> 40c40
> <     xterm-color|*-256color) color_prompt=yes;;
> ---
>>      xterm-color) color_prompt=yes;;
> 46c46
> < #force_color_prompt=yes
> ---
>> force_color_prompt=yes
> 113a114,124
> [...]

>
> it appears that I set:
> force_color_prompt=yes
> in my ~/.bashrc . And that actually gives me color'ed mr@gdOv:~$ (I'm not an
> expert as I often admit.)


     I always use color, as you. The statement that prompt is more 
important than command output is just plain wrong. I use the same color 
as you (green for me and red for root), plus other fancy colours for 
other system usernames (eg www-data). It is very important also to 
remind you when you are in a chroot. Here is my prompt for root (note 
the color list in the comment):


----------------------------
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
     debian_chroot=$(cat /etc/debian_chroot)
fi


# set a fancy prompt (non-color, unless we know we "want" color)
# \[\033[01;XXm\] changes the color
# with XX= 30->black-bold, 31->red, 32->green, 33->yellow, 34->blue, 
35->cyan
# and  \[\033[00m\] to return to the default color
case "$TERM" in
xterm*)
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ 
'
     ;;
*)
     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
     ;;
esac
----------------------------


     Cheers.
                                 Didier