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

Re: Funky list-colors



On Fri, Nov 29, 2019 at 12:37 PM zsugabubus
<zsugabubus@xxxxxx> wrote:
>
> On Fri, Nov 29, 2019 at 11:22:52AM -0800, Bart Schaefer wrote:
> > What's the end goal here?
>
> To keep my message short, I wanted to receive a quick visual
> feedback what kind of files I work with. That's where `LS_COLORS` came
> into the view. However, if I'm only using 3-4 colors it looks like a
> rainbow (more colors can be hardly distinguished and remembered).
> [...]
> So after my success story with colors, I started modifying `LS_COLORS`
> to put prefixes before files.

OK, so what you want here is not to fiddle with the way completion
applies colors to the grid, but the way it populates the grid with
file names.

The first and most straightforward thing you might do is set the
LIST_TYPES option (it should be set by default, but maybe it's become
turned off).  This puts an identifiying character at the end of the
file name, e.g., character devices get a "%", block devices get  a
"#", directories a "/", symlinks an "@", etc.  (Oddly I can't find a
complete description of the identifying characters in the manual.)  If
you have this set and are not seeing these marks, it may be because
your completion function is not using "compadd -f" to tell the
internals to treat the names as files.

If that's not sufficient (e.g., you want to differentiate among files
that list_types treats as "plain") then I would presume you are doing
this with a pattern match in the LS_COLORS setting.  In that case you
should look at the file-patterns zstyle, which in combination with the
group-name and descriptions zstyles allows you to split the completion
listing into sections.  This can be a little tricky to get right, so
feel free to post samples of your attempts here if you want help.

If that's still not enough, then you'll want to create your own
completion function to manage these files.  "compadd -P prefix ..."
will attach a prefix to each string added by that call to compadd,
where that prefix is NOT treated as part of the file name, so if you
can make separate calls to compadd for each variety of file you want
to label, you can get exactly what you're looking for.

For even more detail you can use something similar to:
  compadd -o -d labels_array -a filenames_array
where there is one entry in $labels_array for each entry in
$filenames_array.  The completion system will arrange to build a grid
of the labels and names so that each name is paired with the
corresponding element from the labels.  However, it does place the
labels to the right of the names rather than to the left.



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