Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: random attribute stuff
- X-seq: zsh-workers 24960
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: Re: PATCH: random attribute stuff
- Date: Wed, 07 May 2008 17:49:21 +0200
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:Received:In-reply-to:From:References:To:Subject:Date:Message-ID; b=qGBkr3NLjOTXOD3Ug2/7cnQZOBmvv2Cot2d/1ffl266lDqH95vIHWG16ohog/Ik/KAEm19YzKcmOY2lPOBEVzEl0dUrSgh4g4SVrVf4pIqTwepGBKxhvZltcxwAs8F5edrpn8+DDNP3Lv+8lDOMC+UOsoqbAE8l0k8pGePtTBdQ= ;
- In-reply-to: <20080506191611.79fdf69a@news01>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <200805060915.m469FeJP017551@xxxxxxxxxxxxxx> <080506073442.ZM22499@xxxxxxxxxxxxxxxxxxxxxx> <200805061442.m46Eg7bN000588@xxxxxxxxxxxxxx> <080506075838.ZM1161@xxxxxxxxxxxxxxxxxxxxxx> <200805061510.m46FA71C001035@xxxxxxxxxxxxxx> <080506083802.ZM1323@xxxxxxxxxxxxxxxxxxxxxx> <200805061548.m46Fmq2X013524@xxxxxxxxxxxxxx> <20080506191611.79fdf69a@news01>
This is definitely useful. Leaving attributes on at then end of the
prompt is something I always used to do. It still works except that it
all gets messed up by menu completion. I'm not sure about coloured
completion listings because I don't use them. In any case, it was enough
that I stopped leaving attributes on after the prompt.
I've attached a patch which changes prompt_oliver_setup to use
zle_highlight. This fixes things for the interaction with
region_highlight from my bracket matching widget but is still broken
when I use menu completion. It is especially broken if the bold
attribute is set: I get >= symbols around the matches.
Given that zsh now has internal knowledge that "green" is ESC [32m and
so on, would it be wise to allow this in prompt escapes: %A{fg=green}
perhaps? Or maybe support a prompt element in zle_highlight. I've only
ever used single colour prompts. Support for more than 16 colours would
also be good. SGI's terminal supported them 15 years ago.
Oliver
Index: prompt_oliver_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_oliver_setup,v
retrieving revision 1.3
diff -u -r1.3 prompt_oliver_setup
--- prompt_oliver_setup 31 Jan 2002 15:30:42 -0000 1.3
+++ prompt_oliver_setup 7 May 2008 15:24:23 -0000
@@ -23,21 +23,22 @@
[[ "${(t)pcolour}" != assoc* ]] && typeset -Ag pcolour
[[ "${(t)tcolour}" != assoc* ]] && typeset -Ag tcolour
- local pcol=${1:-${pcolour[${HOST:=`hostname`}]:-yellow}}
+ local pcol=${1:-${pcolour[${HOST:=`hostname`}]:-bold}}
local pcolr=$fg[${pcol#bold}]
- [[ $pcol = bold* ]] && pcolr=$bold_color$pcolr
+ [[ $pcol = bold* ]] && pcolr=%B$pcolr
- local tcol=${2:-${tcolour[$HOST]:-white}}
- local tcolr=$reset_color$fg[${tcol#bold}]
- [[ $tcol = bold* ]] && tcolr=$tcolr$bold_color
+ local tcol=${2:-${tcolour[$HOST]}}
+ local tcolr="fg=${tcol#bold}"
+ [[ $tcol = bold* ]] && tcolr=bold,$tcolr
local a host="%m:" user="%n "
[[ $HOST == (${(j(|))~normal_hosts}) ]] && host=""
- [[ ${USER:-`whoami`} == (root|${(j(|))~normal_users}) ]] && user=""
+ [[ $LOGNAME == (root|${(j(|))~normal_users}) ]] && user=""
- PS1="%{$pcolr%}$user$host%~%"'$((COLUMNS-12))'"(l.$prompt_newline.
)[%h%1(j.%%%j.)%0(?..:%?)]%# %{$tcolr%}"
+ PS1="%{$pcolr%}$user$host%~%"'$((COLUMNS-12))'"(l.$prompt_newline.
)[%h%1(j.%%%j.)%0(?..:%?)]%# %{$reset_color%}"
RPS2='<%^'
PS2=''
+ zle_highlight[(r)default:*]=default:$tcolr
}
prompt_oliver_setup "$@"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author