* Would like help with prompt
@ 2006-05-18 9:05 Kyrre Nygard
2006-05-18 9:37 ` Frank Terbeck
0 siblings, 1 reply; 6+ messages in thread
From: Kyrre Nygard @ 2006-05-18 9:05 UTC (permalink / raw)
To: zsh-users
Hello!
This is my prompt (with some nice bolds and colors):
(kyrre@merhaba)(11:01+18/05)
(%:~)
It is set in /etc/zshrc like this:
PROMPT=$'%{\e[01;36m%}(%{\e[22;36m%}%n%{\e[01;30m%}@'
PROMPT+=$'%{\e[22;36m%}%m%{\e[01;36m%})%{\e[01;36m%}%{\e[01;36m%}('
PROMPT+=$'%{\e[22;36m%}%D{%H:%M}%{\e[01;30m%}+%{\e[22;36m%}%D{%d/%m}'
PROMPT+=$'%{\e[01;36m%})%{\e[01;30m\e[00m%}\n%{\e[01;36m%}('
PROMPT+=$'%{\e[22;36m%}%#%{\e[01;30m%}:%{\e[22;36m%}%~%{\e[01;36m%})'
PROMPT+=$'%{\e[01;30m\e[00m%} '
if [[ `whoami` = root ]] then
PROMPT=$'%{\e[01;31m%}(%{\e[22;31m%}%n%{\e[01;30m%}@'
PROMPT+=$'%{\e[22;31m%}%m%{\e[01;31m%})%{\e[01;31m%}%{\e[01;31m%}('
PROMPT+=$'%{\e[22;31m%}%D{%H:%M}%{\e[01;30m%}+%{\e[22;31m%}%D{%d/%m}'
PROMPT+=$'%{\e[01;31m%})%{\e[01;30m\e[00m%}\n%{\e[01;31m%}('
PROMPT+=$'%{\e[22;31m%}%#%{\e[01;30m%}:%{\e[22;31m%}%~%{\e[01;31m%})'
PROMPT+=$'%{\e[01;30m\e[00m%} '
fi
However this setup is darn ugly.
So I've been trying to simplify and adding some order to it:
I know I could load `colors' but I'm not sure if my colors are
available. Anyway ...
local a1="01;36m"
local a2="22;36m"
local a3="01;30m"
local b1="01;31m"
local b2="22;31m"
local b3="01;30m"
PROMPT=$'%{$a1}(%{$a2}%n%{$a3}@%{$a2}%m%{$a1})'
PROMPT+=$'%{$a1}('{$a2}%D{%H:%M}%{$a3}+%{$a2}%D{%d/%m}%{$a1})%{$a3}\n'
PROMPT+=$'%{$a1}(%{$a2}%#%{$a3}:%{$a2}%~%{$a1})'
if [[ `whoami` = root ]] then
PROMPT=$'%{$b1}(%{$b2}%n%{$b3}@%{$b2}%m%{$b1})'
PROMPT+=$'%{$b1}%{$b1}(%{$b2}%D{%H:%M}%{$b3}+%{$b2}%D{%d/%m}%{$b1})%{$b3}\n'
PROMPT+=$'%{$b1}(%{$b2}%#%{$b3}:%{$b2}%~%{$b1})'
fi
But so far that doesn't work:
/etc/zshrc:32: parse error near `)'
$a1}($a2}kyrre$a3}@$a2}merhaba$a1})
Maybe somebody out there can offer me some help?
Thanks a lot,
Kyrre
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Would like help with prompt
2006-05-18 9:05 Would like help with prompt Kyrre Nygard
@ 2006-05-18 9:37 ` Frank Terbeck
2006-05-18 10:31 ` Kyrre Nygard
0 siblings, 1 reply; 6+ messages in thread
From: Frank Terbeck @ 2006-05-18 9:37 UTC (permalink / raw)
To: zsh-users
Kyrre Nygard <kyrreny@broadpark.no>:
[...]
> However this setup is darn ugly.
Agreed. :-)
> I know I could load `colors' but I'm not sure if my colors are
> available. Anyway ...
I'd really check if 'colors' wouldn't do:
[snip]
% print -l $color | sort | column
00 32 44 cyan
01 32 45 default
02 33 46 faint
03 33 47 green
04 34 49 magenta
05 34 bg-black no-blink
07 35 bg-blue no-reverse
08 35 bg-cyan no-standout
22 36 bg-default no-underline
23 36 bg-green none
24 37 bg-magenta normal
25 37 bg-red red
27 39 bg-white reverse
30 39 bg-yellow standout
30 40 black underline
30 40 blink white
30 41 blue yellow
31 42 bold
31 43 conceal
[snap]
AFAICS you are using bold, normal, black, cyan and red.
These would be available by loaded 'colors' arrays.
Regards, Frank
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Would like help with prompt
2006-05-18 9:37 ` Frank Terbeck
@ 2006-05-18 10:31 ` Kyrre Nygard
2006-05-18 10:32 ` Kyrre Nygard
2006-05-18 10:44 ` Frank Terbeck
0 siblings, 2 replies; 6+ messages in thread
From: Kyrre Nygard @ 2006-05-18 10:31 UTC (permalink / raw)
To: Frank Terbeck, zsh-users
At 11:37 18.05.2006, Frank Terbeck wrote:
>Kyrre Nygard <kyrreny@broadpark.no>:
>[...]
> > However this setup is darn ugly.
>
>Agreed. :-)
>
> > I know I could load `colors' but I'm not sure if my colors are
> > available. Anyway ...
>
>I'd really check if 'colors' wouldn't do:
>
>[snip]
> % print -l $color | sort | column
> 00 32 44 cyan
> 01 32 45 default
> 02 33 46 faint
> 03 33 47 green
> 04 34 49 magenta
> 05 34 bg-black no-blink
> 07 35 bg-blue no-reverse
> 08 35 bg-cyan no-standout
> 22 36 bg-default no-underline
> 23 36 bg-green none
> 24 37 bg-magenta normal
> 25 37 bg-red red
> 27 39 bg-white reverse
> 30 39 bg-yellow standout
> 30 40 black underline
> 30 40 blink white
> 30 41 blue yellow
> 31 42 bold
> 31 43 conceal
>[snap]
>
>AFAICS you are using bold, normal, black, cyan and red.
>These would be available by loaded 'colors' arrays.
>
>Regards, Frank
Cool stuff, thanks man!
Although, what does each column represent?
I'm still on a "which is really the colors in my prompt" since
I haven't gotten by the whole:
/etc/zshrc:32: parse error near `)'
$a1}($a2}kyrre$a3}@$a2}merhaba$a1})
Stage so I can test them all yet.
I also have a dark grey color which doesn't seem to be on this list.
Thanks so far though!
All the best,
Kyrre
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Would like help with prompt
2006-05-18 10:31 ` Kyrre Nygard
@ 2006-05-18 10:32 ` Kyrre Nygard
2006-05-18 10:44 ` Frank Terbeck
1 sibling, 0 replies; 6+ messages in thread
From: Kyrre Nygard @ 2006-05-18 10:32 UTC (permalink / raw)
To: zsh-users
Hello again!
One more thing, to specify colors, will this do?
local a1="01;36m"
Or do I have to make them this ugly?
local a1=$'%{\e[01;36m%}'
:) Thanks guys,
-- Kyrre
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Would like help with prompt
2006-05-18 10:31 ` Kyrre Nygard
2006-05-18 10:32 ` Kyrre Nygard
@ 2006-05-18 10:44 ` Frank Terbeck
2006-05-18 17:32 ` Kyrre Nygard
1 sibling, 1 reply; 6+ messages in thread
From: Frank Terbeck @ 2006-05-18 10:44 UTC (permalink / raw)
To: zsh-users
Kyrre Nygard <kyrreny@broadpark.no>:
> At 11:37 18.05.2006, Frank Terbeck wrote:
> >I'd really check if 'colors' wouldn't do:
> >
> >[snip]
> > % print -l $color | sort | column
> > 00 32 44 cyan
[...]
> >[snap]
>
> Cool stuff, thanks man!
>
> Although, what does each column represent?
That's just a representation of an associative array.
See 'man zshcontrib'. And try:
% autoload colors ; colors
% print $fg[red]$bg[white]Hello World.
% PS1="%{${fg[yellow]}%}%/ %{${fg[default]}%}%# "
Regards, Frank
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Would like help with prompt
2006-05-18 10:44 ` Frank Terbeck
@ 2006-05-18 17:32 ` Kyrre Nygard
0 siblings, 0 replies; 6+ messages in thread
From: Kyrre Nygard @ 2006-05-18 17:32 UTC (permalink / raw)
To: Frank Terbeck, zsh-users
At 12:44 18.05.2006, Frank Terbeck wrote:
>Kyrre Nygard <kyrreny@broadpark.no>:
> > At 11:37 18.05.2006, Frank Terbeck wrote:
> > >I'd really check if 'colors' wouldn't do:
> > >
> > >[snip]
> > > % print -l $color | sort | column
> > > 00 32 44 cyan
>[...]
> > >[snap]
> >
> > Cool stuff, thanks man!
> >
> > Although, what does each column represent?
>
>That's just a representation of an associative array.
>See 'man zshcontrib'. And try:
>
>% autoload colors ; colors
>% print $fg[red]$bg[white]Hello World.
>% PS1="%{${fg[yellow]}%}%/ %{${fg[default]}%}%# "
>
>Regards, Frank
I came up with this elegant approach thanks to Dan Nelson
from the FreeBSD mailinglist:
if [[ $USER == root ]] ; then
a1="%{$fg_bold[cyan]%}"
a2="%{$fg_no_bold[cyan]%}"
a3="%{$fg_bold[black]%}"
else
a1="%{$fg_bold[red]%}"
a2="%{$fg_no_bold[red]%}"
a3="%{$fg_bold[black]%}"
fi
PROMPT="$a1($a2%n$a3@$a2%m$a1)($a2%D{%H:%M}$a3+$a2%D{%d/%m}$a1)"$'\n'
PROMPT+="$a1($a2%#$a3:$a2%~$a1) %{$reset_color%}"
Nice isn't it?
All the best,
Kyrre
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-05-18 17:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-18 9:05 Would like help with prompt Kyrre Nygard
2006-05-18 9:37 ` Frank Terbeck
2006-05-18 10:31 ` Kyrre Nygard
2006-05-18 10:32 ` Kyrre Nygard
2006-05-18 10:44 ` Frank Terbeck
2006-05-18 17:32 ` Kyrre Nygard
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).