zsh-workers
 help / color / mirror / code / Atom feed
From: "Owen M. Astley" <oma1000@cam.ac.uk>
To: Ollivier Robert <roberto@eurocontrol.fr>
Cc: zsh-workers@sunsite.auc.dk
Subject: Re: Stopping completion from using $cdpath
Date: Thu, 16 Sep 1999 17:44:11 +0100 (BST)	[thread overview]
Message-ID: <Pine.OSF.3.96.990916173849.26701A-100000@alpha11.poco.phy.cam.ac.uk> (raw)
In-Reply-To: <19990916182813.A19091@caerdonn.eurocontrol.fr>

> Is there a way to stop zsh from using $cdpath when doing completion ? If I
> have a directory with only one sub-directory and I do
> 
> cd <TAB>
> 
> it tries to complete from $cdpath instead of directly going into the
> sub-directory. If I unset cdpath, it works fine...

I use this function to allow completion from cdpath of all files (or at
least those files that are following the default completion), so for
example

alpha11-~/private% echo $cdpath
./ /u/pol1b/oma1000/
alpha11-~/private% cd<tab>
cv/       eric/     igor/     letters/  rm/
alpha11-~/private% ls -d ~/*(/)
/u/pol1b/oma1000/LaTeX/         /u/pol1b/oma1000/mail/
/u/pol1b/oma1000/Mail/          /u/pol1b/oma1000/misc/
/u/pol1b/oma1000/News/          /u/pol1b/oma1000/nsmail/
/u/pol1b/oma1000/apps/          /u/pol1b/oma1000/pc/
/u/pol1b/oma1000/carol/         /u/pol1b/oma1000/private/
/u/pol1b/oma1000/cerius/        /u/pol1b/oma1000/public_html/
/u/pol1b/oma1000/data/          /u/pol1b/oma1000/teaching/
/u/pol1b/oma1000/diagrams/      /u/pol1b/oma1000/tensile/
/u/pol1b/oma1000/instructions/  /u/pol1b/oma1000/theory/
/u/pol1b/oma1000/local/         /u/pol1b/oma1000/unit-cells/
alpha11-~/private% cd m<tab>  [the m then gets changed to ~/m]
~/mail/  ~/misc/

Hope this makes sense!

Owen

# zsh function
# compctl-cdpath

# Completion for general globbing, completing for stuff in cdpath,
# uses directories listed in cdpath, and replaces ... with ../.. .

# Usage:
# compctl -D -f + -QU -S '' -K compctl-cdpath

######################################################################
local pref="${1:fs|...|../..|}"
integer i

setopt localoptions
setopt nullglob rcexpandparam
unsetopt rcexpandparam markdirs equals

reply=()

######################################################################
# Anything starting with `~' or `=' isn't handled by compctl-cdpath.
[[ $pref[1] == [\~\=] ]] && return

# Check if the completion exists in the current directory.
reply=(${pref}*)

# If the completion doesn't exist in the current directory, use cdpath.
[[ -z $reply ]] && reply=("${(@)reply}" ${^cdpath%/}/${pref}*)

# If there were no completions, return $pref (allowing ... -> ../..)
[[ -z $reply ]] && reply=("$pref")

# Replace reply with a nicer version.
unset pref origpref
reply=($(print -D "${(@)reply}"))

######################################################################
# Add / to all directories, spaces to files.
i=1
while (( i <= ${(w)#reply} )); do
  [[ -d ${~reply[i]}/ ]] && reply[i]="${reply[i]%/}/"
  [[ -f ${~reply[i]} ]] && reply[i]="$reply[i] "
  ((i++))
done



      parent reply	other threads:[~1999-09-16 16:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-16 16:28 Ollivier Robert
1999-09-16 16:30 ` Andrej Borsenkow
1999-09-16 16:44 ` Owen M. Astley [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=Pine.OSF.3.96.990916173849.26701A-100000@alpha11.poco.phy.cam.ac.uk \
    --to=oma1000@cam.ac.uk \
    --cc=roberto@eurocontrol.fr \
    --cc=zsh-workers@sunsite.auc.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).