From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25306 invoked from network); 18 Nov 1998 19:28:26 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 18 Nov 1998 19:28:26 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id OAA27750; Wed, 18 Nov 1998 14:27:25 -0500 (EST) Resent-Date: Wed, 18 Nov 1998 14:27:25 -0500 (EST) From: "Bart Schaefer" Message-Id: <981118112559.ZM12272@candle.brasslantern.com> Date: Wed, 18 Nov 1998 11:25:59 -0800 In-Reply-To: <199811180909.KAA14049@beta.informatik.hu-berlin.de> Comments: In reply to Sven Wischnowsky "Re: bug 3.1.5 symlinks & cd" (Nov 18, 10:09am) References: <199811180909.KAA14049@beta.informatik.hu-berlin.de> X-Mailer: Z-Mail (4.0b.820 20aug96) To: zsh-workers@math.gatech.edu Subject: Re: bug 3.1.5 symlinks & cd MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"wU9AI2.0.Xn6.S-nKs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4671 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Nov 18, 10:09am, Sven Wischnowsky wrote: } Subject: Re: bug 3.1.5 symlinks & cd } } > [...] different parts of the shell are taking differing approaches to } > symbolic-links pointing to directories. Completion ignores the symbolic } > aspect of PWD, such that a ../ always uses the underlying 'true' layout, } > whilst cd handles the symbolic links. This is a conflict that's } > entirely due to two parts of zsh doing things very differently. } } A (partial) solution is to use a shell function, like this: } } compctl -K cdcomp -S/ -q cd pushd } } cdcomp() { } local d r } if [[ "$1" == */* ]] } then } d="${1%%/*}" } r="${1#*/}" } cd "$d" >& /dev/null } reply=( ${r}*${2}(N-/) ) } reply=( $d/$reply ) Should be: reply=( $d/$^reply ) } cd - >& /dev/null } else } reply=( ${1}*${2}(N-/) ) } fi } } That's an unpleasant solution because it silently changes the value of $OLDPWD, messing up the use of ~- in filename expansions. One possible workaround: cdcomp() { local d r if [[ "$1" == */* ]] then d="${1%%/*}" r="${1#*/}" reply=( "${(@f)$( cd "$d" >& /dev/null print -l ${r}*${2}(N-/) )}" ) reply=( $d/$^reply ) else reply=( ${1}*${2}(N-/) ) fi } "${(@f)$(print -l ...)}" in case some of the directory names have spaces. On Nov 18, 2:06pm, Peter Stephenson wrote: } Presumably it will one day become possible to replace the (../)# with } a truncated version of $PWD, then reapply -/ using the -W option to } compctl to generate the completions you want. Then the script } solution ought to become pretty painless. Hmm. compctl -/ -x 'S[../]' -S/ -q -K cdcomp -- cd cdcomp() { local h t p d # No, not Apache :-) h="${(M)1##*../}" # Extract leading (../)# t="${1##*../}" # Delete leading (../)# p="${h:gs@../@/*@}" # Convert $h to a pattern eval 'd="${PWD%'"$p"'}"' # Remove matching tail of $PWD reply=( $d/$t*$2(N-/) ) # Generate list of directories eval 'reply=( ${reply'":s@$d/$t@$1@"'} )' # Fix up prefixes } The last line fails on directories with "@" in their names, and the first two fail on things like ../foo/bar/../baz/. Oh, well. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com