Zsh Mailing List Archive
Messages sorted by:
Re: Ignoring current directory with auto_cd
- X-seq: zsh-users 21884
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Ignoring current directory with auto_cd
- Date: Mon, 12 Sep 2016 17:24:21 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=gtmYpaefSn1MdGSKCb5Kn0vOssaoX/rELv8cV8WRQm4=; b=Bi5bZARkXcWRPyC77tDl24JXp2rsdx405/oQ6E6kOjJkb6kN28OP2zA9KiJNu0oqmR wcnh+/Bv+HqxxQ0uCyxA9xLxmilvIzefICLnGjgnSm+IbCBSbV3EGUbOrH91EdvH7uSb ROX8tNaCgaRIYS2ab6YurRbbuj9r4yGnhwS/TUkqGWJHn4oZZYEl4h5LsXfb3Ev+dHyB L3tDXsVtcszvYSrHlBvIs0iPf1ZqEPa/tZc1loxd5bT96ocKvnxsDroGUAaxYVWse09u tQJhS3+2iehhunyICLVjQ+MDYAB/+CKOmeKG2GD7utagVOKAs4sczPswDltw2fvQehhf YVWw==
- In-reply-to: <CABZhJg9-+v2BpGyD62=yae14KEsaK6ZC8jRZLnQup3R6jJg8CQ@mail.gmail.com>
- List-help: <mailto:email@example.com>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CABZhJg9se+WgA+tdvxKTd+UeHFLWibQpnqmOr=AAHBr4mz_DSg@mail.gmail.com> <160912102321.ZM24807@torch.brasslantern.com> <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.
Messages sorted by: