home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / ap / zsh / zsh-2.4 / zsh-2 / zsh-2.4.306 / func / cdmatch < prev    next >
Text File  |  1993-09-06  |  787b  |  36 lines

  1. # Start of cdmatch.
  2. # Save in your functions directory and autoload, then do
  3. #   compctl -K cdmatch -S '/' cd pushd
  4. # or if you prefer
  5. #   compctl -K cdmatch -S '/' -x 'S[/][~]' -g '*(-/)' -- cd pushd
  6. # (to use ordinary globbing for absolute paths).
  7. #
  8. # Completes directories for cd, pushd, ... anything which knows about cdpath.
  9. # Note that . is NOT automatically included.  It's up to you to put it in
  10. # cdpath somewhere.
  11.  
  12. local dir nword args pref ngtrue
  13.  
  14. [[ -o nullglob ]] && ngtrue=1
  15. setopt nullglob
  16.  
  17. read -nc nword
  18. read -Ac args
  19. pref=$args[$nword]
  20.  
  21. if [[ $pref[1] = [/\~] ]]; then
  22.   eval "reply=($pref*(-/))"
  23. else
  24.   reply=()
  25.  
  26.   for dir in $cdpath
  27.   do
  28.     eval "reply=(\$reply $dir/$pref*(-/:s,$dir/,,))"
  29.   done
  30. fi
  31.  
  32. [[ $ngtrue = 1 ]] || unsetopt nullglob
  33.  
  34. return
  35. # End of cdmatch.
  36.