From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8548 invoked from network); 16 Sep 1999 16:44:19 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 16 Sep 1999 16:44:19 -0000 Received: (qmail 23657 invoked by alias); 16 Sep 1999 16:44:12 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7879 Received: (qmail 23650 invoked from network); 16 Sep 1999 16:44:12 -0000 Date: Thu, 16 Sep 1999 17:44:11 +0100 (BST) From: "Owen M. Astley" X-Sender: oma1000@alpha11.poco.phy.cam.ac.uk To: Ollivier Robert cc: zsh-workers@sunsite.auc.dk Subject: Re: Stopping completion from using $cdpath In-Reply-To: <19990916182813.A19091@caerdonn.eurocontrol.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII > 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 > > 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 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 [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