From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id EAA10334 for ; Thu, 29 Aug 1996 04:15:48 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id OAA11191; Wed, 28 Aug 1996 14:11:54 -0400 (EDT) Resent-Date: Wed, 28 Aug 1996 13:55:10 -0400 (EDT) From: "Bart Schaefer" Message-Id: <960828104915.ZM9719@candle.brasslantern.com> Date: Wed, 28 Aug 1996 10:49:15 -0700 In-Reply-To: "C. v. Stuckrad" "How to complete commands on a different/generated PATH ?" (Aug 28, 5:22pm) References: Reply-To: schaefer@nbn.com X-Mailer: Z-Mail (4.0b.820 20aug96) To: "C. v. Stuckrad" , zsh-users@math.gatech.edu Subject: Re: How to complete commands on a different/generated PATH ? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"nS7gi2.0.jg2.-V89o"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/393 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Aug 28, 5:22pm, C. v. Stuckrad wrote: } Subject: How to complete commands on a different/generated PATH ? } } We use a set of macros 'x11x' 'ow3x' '...some_other_s', which } manipulate the environment to start a program in the 'correct world'. } } BUT HOW TO 'first change the PATH, then glob on the new PATH' ? The best way to do this depends on what you mean by "macro". If it's nothing more than a zsh alias that expands to a PATH=... assignment, there might be some tricks to play. However: ---------- function Xcomplete { emulate -R zsh setopt localoptions local nword args read -nc nword read -Ac args reply=($( case $args[0] in (x11x) PATH=the:path:used:by:x11x ;; # Change these suitably for (ow3x) PATH=the:path:used:by:ow3x ;; # each of your macros' PATH esac rehash whence -pm ${args[$nword]:t}\* )) reply=(${reply##*/}) } compctl -x 'p[1]' -K Xcomplete - 'p[2,-1]' -l '' -- x11x ow3x ---------- Note the use of the new "case" syntax. There is STILL a bug in parsing of "case" statements inside $( ... ) which causes the old-style "case" to fail. Vis: zsh% echo $( cmdsubst> case foo in cmdsubst> foo) zsh: parse error near `foo' zsh: parse error in command substitution The close-paren in the "case" pattern ends the $( ... ) parse. Of course, this doesn't work in bash either, and is probably the reason that POSIX created the new case syntax .... Oh, there is one small nit about the above function: Because of the way "whence" works, it returns x11x, ow3x, and Xcomplete as possible completions. So you can end up with: zsh% x11x x11x ow3x ... and it'll still be happily completing away. You can use extend it to strip those out if you want. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.nbn.com/people/lantern New male in /home/schaefer: >N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday"