zsh-workers
 help / color / mirror / code / Atom feed
From: Julius Plenz <julius@plenz.com>
To: zsh-workers@sunsite.dk
Subject: Re: Module zsh/complist and coloring
Date: Sat, 30 Aug 2008 16:16:55 +0200	[thread overview]
Message-ID: <20080830141655.GL16053@plenz.com> (raw)
In-Reply-To: <20080830124321.7990824d@pws-pc>

Hi!

* Peter Stephenson <p.w.stephenson@ntlworld.com> [2008-08-30 13:43]:
> Julius Plenz <julius@plenz.com> 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


      reply	other threads:[~2008-08-30 14:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-27 14:02 Julius Plenz
2008-08-30 11:43 ` Peter Stephenson
2008-08-30 14:16   ` Julius Plenz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080830141655.GL16053@plenz.com \
    --to=julius@plenz.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).