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

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



On Fri 03 Sep 2021 at 02:45:03 (+0100), piorunz wrote:
> On 03/09/2021 01:34, David Wright wrote:
> > (I use my own customisations for distinct colours on each host,
> > and inverse colours for root's prompt.)
> 
> Can you please share your root prompt invocation? Thanks!

Sure. The colours come from a set of files by hostname:

$ 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
        PS1='\['$(tput setaf 3)$(tput setab 1)'\]$Myprompt\['$(tput bold)$(tput setaf 7)$(tput setab "$Hue")'\]\H \t \w\['$(tput sgr0)'\]\$ '
    else
        PS1='—$Myprompt—\H \t \w\$ '
    fi

    #hexdump -C <<<"$PS1"

fi

Cheers,
David.


Reply to: