zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: <zsh-users@zsh.org>
Subject: Re: how to make zsh tab-complete path after colon (instead of just `=`)
Date: Tue, 8 Jan 2019 11:21:24 +0000	[thread overview]
Message-ID: <1546946484.4090.2.camel@samsung.com> (raw)
In-Reply-To: <CANri+EwBAn0zjbQ6rbRjixXVRqqv3fE2Y3VMSvDhAy+t35zBPg@mail.gmail.com>

On Tue, 2019-01-08 at 01:49 -0800, Timothee Cour wrote:
> is it possible make zsh complete filenames after a colon (instead of
> just after `=`) ?
> t foo=/tm<TAB> autocomples with /tmp
> t foo:/tm<TAB> doesn't do any autocomplete
> 
> (IIRC  in bash COMP_WORDBREAKS can be used for that)
> I don't want to specify this rule for every single command, I want it
> to apply to all commands by default

Generally speaking, zsh doesn't work like that --- it will perform
completion after colons in cases where that actually make sense, e.g. in
assignments to path variables etc.  So the right answer would indeed be
to make this happen in completions for the t command.

If you really want a brutal answer, however, it's not so hard to add a
style that will allow you to split all file completions on a given set
of characters.  The following simple patch allows you to set

zstyle ':completion:*' file-split-chars :

Given how brutal this is, I can well imagine there are cases this fails
horribly.  It is at least safe in the sense that if you don't set the
style nothing nasty will happen, and you have the usual style context
syntax to limit its application.  So it's probably about the best you're
likely to get.

pws

diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index 9fa6ae9..1021c34 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -2,6 +2,11 @@
 
 local -a match mbegin mend
 
+local splitchars
+if zstyle -s ":completion:${curcontext}:" file-split-chars splitchars; then
+  compset -P "*[${(q)splitchars}]"
+fi
+
 # Look for glob qualifiers.  Do this first:  if we're really
 # in a glob qualifier, we don't actually want to expand
 # the earlier part of the path.  We can't expand inside


  reply	other threads:[~2019-01-08 11:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190108095220epcas2p1220c2b5ad3e9401282d243bcfea7ada1@epcas2p1.samsung.com>
2019-01-08  9:49 ` Timothee Cour
2019-01-08 11:21   ` Peter Stephenson [this message]
2019-01-08 12:37     ` Peter Stephenson
2019-01-08 15:32       ` Daniel Shahaf

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=1546946484.4090.2.camel@samsung.com \
    --to=p.stephenson@samsung.com \
    --cc=zsh-users@zsh.org \
    /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).