[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PS1 multiline with colors
From: |
Greg Wooledge |
Subject: |
Re: PS1 multiline with colors |
Date: |
Fri, 5 Jul 2013 08:30:48 -0400 |
User-agent: |
Mutt/1.4.2.3i |
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 <=
- RE: PS1 multiline with colors, BASTIDON , Stéphane, 2013/07/05
- 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