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

colors_plus



Hi all,

To be honest I wrote the following with the intent to send it to zsh-users, but the
more I thought about it I decided to first ask those on zsh-workers for your
thoughts and opinions.

For lack  of a better name, "colors_plus" for now.  This is a function I have been
trying to think through as an addition to the current colors function. It should work
on at least some virtual terminals(best guess). Doesn't work on the linux console,
so colors would still be needed.

Attached is the function colors_plus_test.  It is also a wip(work in progress) so has a
number of notes and comments.  Also code that is commented out that was used
for testing, that may or may not have worked out. It needs a lot of cleanup, to say
the least, but should be good enough for testing. It should show what a virtual
terminal is capable of outputting. Results can only be determined by visual
observation.

Anyway I was hoping that some on this list would run the function and give  me
feedback on what you think of the output. It has several defaults so autoloading
the function and then typing the function's name will give you 8 lines of output.
The 8 colors match those used in the colors function. There is a 27 colors option
with color names. There is a 64 color options, but it doesn't have color names, if
you care to look. BTW some of the 27 color names couldn't be found in files like
rgb.txt. Lots of google searches to come up with some of the names.  I'm open
to suggestions on color names too. The shorter the name, the better it would be.

Command line arguments for colors_plus_test are:
  [1|2|3]  the number of colors to output 1) 8 (default), 2) 27 and 3) 64 colors
  [n|b|d] **  n) for normal text output(default), b) for bold and d) for dim
  [i|f|r|u|s|c] ** These can be used in any combination from none to all of them.
    Although some combinations will be useless for most people.
    i) italic, f) flash, r) reverse, u) underscore, s) strikethrough and c) conceal

** case insensitive

Examples:
  colors_plus_test  -- defaults to "colors_plus_test 1 n" 8 colors and normal
  colors_plus_test 2 b i r  -- outputs 27 colors as bold italic reverse
  colors_plus_test d  -- outputs 8 colors as dim
  ...

Requirements:
  Colors_plus uses the module zsh/nearcolor to convert the hex input to a usable
  output. The zsh man page suggests checking the COLORTERM parameter to see
  if it is equal to either 24bit or truecolor to load the module.  xterm doesn't set this
  parameter, but the function will work with xterm if TERM is set to xterm-256color.
  For those using TMUX, on an xterm, TERM set to tmux-256color will also work.
  Haven't tested TMUX running on other terminals yet.

Tested on the following virtual terminals and appears to work:
  xterm
  xfce4-terminal

Tested on the following virtual terminals with mixed results:
kitty - also doesn't work well with 'colors function'

Parameter(s) and elements:
  For the function colors_plus, which I'm working on, I'm considering using one
  associative array "CP" with element names something like:
  Would the following be to obscure for most to use?
  ${CP[2nfi_electric_blue]}
     2 - number of colors
     n - normal
     fi - flash italic , note these letters would be in alphabetical order for consistency
    _ - separator
     colorname - name of the color to display

As I said, comments are welcome. Are 8 colors enough? Are 27 colors to many?
So fire away!  Also haven't tested on a bright(white) background.

Regards and thanks,

Jim Murphy

Attachment: colors_plus_test
Description: Binary data



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