zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Ignoring current directory with auto_cd
Date: Mon, 12 Sep 2016 17:24:21 -0700	[thread overview]
Message-ID: <160912172421.ZM26209@torch.brasslantern.com> (raw)
In-Reply-To: <CABZhJg9-+v2BpGyD62=yae14KEsaK6ZC8jRZLnQup3R6jJg8CQ@mail.gmail.com>

On Sep 12,  9:43pm, Jesper Nygards wrote:
}
} [...] I have "zstyle ':completion:*:cd:*' ignore-parents parent pwd" set
} [...]
} However, if I only type "../s<tab>" (at the beginning of the command line),
} "src" will be one of the alternatives offered by completion. I realize this
} is because the completion system cannot know that it should exclude the
} current directory.

Actually it's not because the system doesn't know it should exclude the
current directory -- it's because the system doesn't know if you're
intending to type the name of a directory, or if you are intending to
type the path to a command file that happens to be inside some ../s*
directory.  In that word position, it has to complete both directory
names and command names, and the latter might include a relative path
as a prefix.

} So my question was: can I use something similar to the zstyle for cd
} completion to always exclude the current directory in such a situation?

If you never want to complete the path prefixes of non-absolute command
name paths, you can do this:

zstyle -e ':completion::complete:-command-::' tag-order \
    '[[ $words[CURRENT] = */* && $words[CURRENT] != /* ]] && reply=(
        commands executables builtins functions aliases
        suffix-aliases reserved-words jobs parameters -
	)'

This will complete all the usual things in command position except
that commands and executables are normally further subdivided by _files
into globbed-files, directories, and all-files, which the trailing "-"
will force to be excluded.

You can get fancier with the conditional expression, e.g., check for
$words[CURRENT]*/**/*(*) finding something, or some such.


      reply	other threads:[~2016-09-13  0:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12 12:32 Jesper Nygårds
2016-09-12 17:23 ` Bart Schaefer
2016-09-12 19:43   ` Jesper Nygårds
2016-09-13  0:24     ` Bart Schaefer [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=160912172421.ZM26209@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).