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

Re: color




On 2023-02-03 20:25, Bart Schaefer wrote:

The first thing you should do is try to get rid of the calls to "sed".
You'll be happier in the long run if you don't have to keep adding
increasingly baroque regular expressions.

I'm happy with the condensation to single letter identifiers, it keeps the display narrow and justified.  I had thought/hoped/wanted 'typeset -mp' to show them but it doesn't. And it makes it easy to see patterns.   Probably better done with native zsh replacements  tho.  I have it so you can optionally view the entire string too.  Very nice to have that. Self-explaining output.  This is zsh being friendly.


2 /aWorking/Zsh/Source/Wk 0 $ . v; v ,f z*

scalar:  Z = /aWorking/Zsh
array:  zle_bracketed_paste = ( $'\C-[[?2004h' $'\C-[[?2004l' )
scalar:  ZSH_ARGZERO = zsh
scalar:  ZSHBOOT = /aWorking/Zsh/Boot
scalar-readonly-tied-special:  ZSH_EVAL_CONTEXT = toplevel:shfunc:cmdsubst
array-readonly-tied-special:  zsh_eval_context = ( toplevel shfunc cmdsubst )
scalar:  ZSH_NAME = zsh
scalar:  ZSH_PATCHLEVEL = debian/5.8-6+deb11u1
array-readonly-hide-hideval-special: zsh_scheduled_events = !hidden!
integer-readonly-special:  ZSH_SUBSHELL = 1
scalar:  ZSH_VERSION = 5.8

2 /aWorking/Zsh/Source/Wk 0 $ . v; v z*

S     Z = /aWorking/Zsh
A     zle_bracketed_paste = ( $'\C-[[?2004h' $'\C-[[?2004l' )
S     ZSH_ARGZERO = zsh
S     ZSHBOOT = /aWorking/Zsh/Boot
Srts  ZSH_EVAL_CONTEXT = toplevel:shfunc:cmdsubst
Arts  zsh_eval_context = ( toplevel shfunc cmdsubst )
S     ZSH_NAME = zsh
S     ZSH_PATCHLEVEL = debian/5.8-6+deb11u1
Arhvs zsh_scheduled_events = !hidden!
Irs   ZSH_SUBSHELL = 1
S     ZSH_VERSION = 5.8


It's not unique, it's an associative array.  Variables like "commands"
(after loading from zsh/parameter module) will show up the same way.
Ok, I'll be on the lookout for others like that.  There's a dozen AAs but none of them display that way -- that I've seen.  'color' seemed unique in how it displays.
You're going to have to have separate cases for each of
scalar/array/associative.  To get both the keys and the values of an
associate array, you need ${(kv)aary}.
Probably not worth the trouble, I was just trying to duplicate 'typeset -m' output via other means and the alternate line I showed comes very close.  I've learned to avoid subshells if I can.  In this case I was just curious about 'print $color' and indeed 'print ${(kv)color}' shows sensible output -- I should have known that -- but I'm not going to attempt separate code for different types. 'typeset -m' is fine tho a bit slower.
This set of threads has gone on long enough, the whole point of your
function is to show you parameter type information so start paying
attention to what's different about THAT and you'll make more
progress.

It's basically finished.  I was just curious about 'colors'.






Messages sorted by: Reverse Date, Date, Thread, Author