[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Why ``color_prompt`` is only set for ``xterm``?



On Sun 05 Sep 2021 at 09:06:31 (-0400), Greg Wooledge wrote:
> On Sat, Sep 04, 2021 at 11:23:48PM -0500, David Wright wrote:
> > $ cat /var/local/lib/myhosts/colours/axis 
> > 5 magenta bbarbutton=white,magenta,none:bbarhotkey=magenta,white,none
> > $ 
> > 
> > 5 is for ANSI colours,
> > magenta is for, eg emacs, mutt, etc,
> > bbarbutton is for mc.
> > 
> > The lines from /root/.bashrc are:
> > 
> > if [[ $- = *i* ]]; then
> > 
> >     export PROMPT_COMMAND='Myprompt="$? " && [ "$Myprompt" = "0 " ] && Myprompt=""'
> > 
> >     # read value from file, and sanitise it
> >     Hue=$(head -c 1 /var/local/lib/myhosts/colours/"$HOSTNAME")
> >     if grep -q ·"$Hue"· <<<"·0·1·2·3·4·5·6·7·8·9·"; then
> 
> It's strange that you used shell builtins for the $- check but not
> for this check.
> 
> read -r Hue _ < /var/local/lib/myhosts/colours/"$HOSTNAME"
> if [[ $Hue = [0-9] ]]; then

Yes. The grep would have been copied from another line in my users'
version of processing that file:
grep -q ·"${Hues[1]}"· <<<"·brown·cyan·green·blue·magenta·red·" && Emacshue="${Hues[1]}"
and when I wrote that, I couldn't be bothered with constructing an OR
(IIRC: 'twas a long time ago).

OTOH   if [[ $- = *i* ]]; then   came from your recent
https://lists.debian.org/debian-user/2021/04/msg00381.html

> Or if you happen to use the other fields of that file later in the script,
> then change the read command to store all 3 fields in shell variables.

I do use an array (as above), but root doesn't, because root only uses
the prompt colour from that file. I don't run emacs, mc or mutt as root.

Two other trivia: root insists on no whitespace at the start, and
I don't think I need to export PROMPT_COMMAND because, unlike you,
I set both it and PS1 in .bashrc.

Cheers,
David.


Reply to: