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

Re: Module zsh/complist and coloring



Hi!

* Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> [2008-08-30 13:43]:
> Julius Plenz <julius@xxxxxxxxx> wrote:
> > Since you cannot download non-files, it'd make sense to have a
> > possibility to tell compadd or the complist module that the
> > matches are all valid filenames, no need for checking that.
> 
> Sounds plausible, although you'd only get half the full effect
> unless you could also supply the file type (most particularly
> directory or regular file).

Well, you can! In that same mail I also wrote:

> But especially for _remote_files, from the trailing slash you can
> tell directories from files apart.

I figured out a way to emulate the coloring, although (because you
don't have access to the file attributes) you can color the matches
only per extension. This snippet displays directories and files in the
colors supplied by $LS_COLORS:

  scp_colors=("=(#b)(*)/=0="${${${(s.:.)LS_COLORS}[(r)di=<->]}/di=/})
  for c (${(s.:.)LS_COLORS})
    [[ $c == \** ]] && scp_colors+=('='$c)
  zstyle ':completion::*:scp:*' list-colors $scp_colors
  unset scp_colors

Actually, you can boil this down to a single zstyle call:

  zstyle ':completion::*:scp:*' list-colors \
    "=(#b)(*)/=0="${${${(s.:.)LS_COLORS}[(r)di=<->]}/di=/} \
    '='${^${(M)${(s.:.)LS_COLORS}:#\**}}

Of course, the coloring for local files is also changed when you want
to upload local files using scp. I don't think there's a way to tell
from the context whether you're completing local or remote files. This
solution is not too bad, though.

Greetings,
Julius



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