zsh-workers
 help / color / mirror / code / Atom feed
* Stopping completion from using $cdpath
@ 1999-09-16 16:28 Ollivier Robert
  1999-09-16 16:30 ` Andrej Borsenkow
  1999-09-16 16:44 ` Owen M. Astley
  0 siblings, 2 replies; 3+ messages in thread
From: Ollivier Robert @ 1999-09-16 16:28 UTC (permalink / raw)
  To: zsh-workers

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...

Thanks,
-- 
Ollivier ROBERT -=- Eurocontrol EEC/TEC -=- roberto@eurocontrol.fr
The Postman hits! The Postman hits! You have new mail.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Stopping completion from using $cdpath
  1999-09-16 16:28 Stopping completion from using $cdpath Ollivier Robert
@ 1999-09-16 16:30 ` Andrej Borsenkow
  1999-09-16 16:44 ` Owen M. Astley
  1 sibling, 0 replies; 3+ messages in thread
From: Andrej Borsenkow @ 1999-09-16 16:30 UTC (permalink / raw)
  To: Ollivier Robert; +Cc: zsh-workers

On Thu, 16 Sep 1999, Ollivier Robert wrote:

> 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...
> 
> Thanks,
> 

cd ./TAB


-- 
------------------------------------------------------------------------
Andrej Borsenkow 		Fax:   +7 (095) 737 2747
Siemens ICP ITS Moscow		Tel:   +7 (095) 737 2723

E-Mail: Andrej.Borsenkow@mow.siemens.ru
-------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Stopping completion from using $cdpath
  1999-09-16 16:28 Stopping completion from using $cdpath Ollivier Robert
  1999-09-16 16:30 ` Andrej Borsenkow
@ 1999-09-16 16:44 ` Owen M. Astley
  1 sibling, 0 replies; 3+ messages in thread
From: Owen M. Astley @ 1999-09-16 16:44 UTC (permalink / raw)
  To: Ollivier Robert; +Cc: zsh-workers

> 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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-09-16 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-16 16:28 Stopping completion from using $cdpath Ollivier Robert
1999-09-16 16:30 ` Andrej Borsenkow
1999-09-16 16:44 ` Owen M. Astley

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).