[Linux-bruxelles] Re: Prompting color

Didier MISSON didier.misson at atofina.com
Lun 28 Juin 13:27:59 CEST 2004


ok, ça marche nikel.

J'ai finalement créé un script  /etc/skel/prompt_init 

---------------------------------------------------------
# hostname en VERT
# user normal avec couleur par défaut
# user root en ROUGE
export PROMPT_HOSTCOLOR='0;32m'
export PROMPT_USERCOLOR='0;39m'
# If I am root, set the prompt to bright red
if [ ${UID} -eq 0 ]; then
PROMPT_USERCOLOR='1;31m'
fi

export 
PS1='\e[${PROMPT_USERCOLOR}\]\u\[\e[m\]@\e[${PROMPT_HOSTCOLOR}\]\h\[\e[m\]:\w\$ 
'

# If this is an xterm set the title to user at host:dir
case $TERM in
xterm*)
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
    ;;
*)
    ;;
esac
--------------------------------------------

Evidemment, je change le PROMPT_HOSTCOLOR  en fonction du serveur.
et j'appelle ce script dans les .bashr  et/ou  .bash_profile  des users 
concernés:

if [ -f /etc/skel/prompt_init ]; then
      . /etc/skel/prompt_init
fi

---------------------------------------------

C'est très clair, et pas trop fashy.
-- 
Didier




Plus d'informations sur la liste de diffusion Linux-bruxelles