Zsh Mailing List Archive
Messages sorted by:
Re: Funky list-colors
- X-seq: zsh-workers 44983
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsugabubus <zsugabubus@xxxxxxx>
- Subject: Re: Funky list-colors
- Date: Wed, 4 Dec 2019 15:27:17 -0800
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- In-reply-to: <20191129203707.ipf4zjkkptg35lpa@localhost>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- List-unsubscribe: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20191129122141.rekf7hcxtacjojo2@localhost> <CAH+w=7ZrwCrhkVCvZUAEgomWT_+bydWHEHV_oaZTDc=rnadyTw@mail.gmail.com> <20191129172303.sd5bj3gukhdb7mpp@localhost> <CAH+w=7ZGsuwPx8jm-mGYqtP6u68kG+-HLkk6fJbaj4rUy+dJVg@mail.gmail.com> <20191129203707.ipf4zjkkptg35lpa@localhost>
On Fri, Nov 29, 2019 at 12:37 PM zsugabubus
> 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
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: