[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: PS1 multiline with colors
From: |
BASTIDON , Stéphane |
Subject: |
RE: PS1 multiline with colors |
Date: |
Fri, 5 Jul 2013 15:29:10 +0000 |
I'll try that asap ...
Thanks
-----Message d'origine-----
De : Greg Wooledge [mailto:wooledg@eeg.ccf.org]
Envoyé : vendredi 5 juillet 2013 14:31
À : BASTIDON, Stéphane
Cc : bug-bash@gnu.org
Objet : Re: PS1 multiline with colors
On Fri, Jul 05, 2013 at 12:21:13PM +0000, BASTIDON, Stéphane wrote:
> Now my case is a little more complex:
> I want my prompt changes colors according to $PWD Then I write something like
> that:
This is the kind of thing where I suggest using PROMPT_COMMAND.
normal=$(tput sgr0) red=$(tput setaf 1) green=$(tput setaf 2) ...
PROMPT_COMMAND='
case $PWD in
/usr/local/*) color=$red ;;
/var/*) color=$green ;;
...
esac
'
PS1='\u@\h:\[$color\]\w\[$normal\]\$ '
export normal red green ... PROMPT_COMMAND PS1
The PROMPT_COMMAND will be evaluated before PS1. You can use it to set
variables that PS1 will use, all without the horrible speed penalty of a
fork/exec.
- PS1 multiline with colors, BASTIDON , Stéphane, 2013/07/04
- Re: PS1 multiline with colors, Chris Down, 2013/07/04
- Re: PS1 multiline with colors, Greg Wooledge, 2013/07/05
- Message not available
- Re: PS1 multiline with colors, Greg Wooledge, 2013/07/05
- RE: PS1 multiline with colors,
BASTIDON , Stéphane <=
- Re: PS1 multiline with colors, Linda Walsh, 2013/07/08
- Re: PS1 multiline with colors, Dan Douglas, 2013/07/09
- Re: PS1 multiline with colors, Geir Hauge, 2013/07/09
- Re: PS1 multiline with colors, Dan Douglas, 2013/07/05