Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: random attribute stuff



Peter wrote:
> > > } It ought to be (but might turn out not to be) fairly easy to add a
> > > } "default" element to zle_highlight that causes the given attributes to

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