* How to complete commands on a different/generated PATH ?
@ 1996-08-28 15:22 C. v. Stuckrad
1996-08-28 17:49 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: C. v. Stuckrad @ 1996-08-28 15:22 UTC (permalink / raw)
To: zsh-users
HI!
I installed zsh3 on our systems, and therefore went through
the new compctl examples. I am missing a special kind of completion
which might be trivial, but I could not (yet :-) find out:
We use a set of macros 'x11x' 'ow3x' '...some_other_s', which
manipulate the environment to start a program in the 'correct world'.
('x11x' starts original X11-Progs under Openwin, 'ow3x' the other way...
all those reorder the PATH to 'prefer' the given environment).
Now if you do NOT have X11 in YOUR PATH and run a completion on the
partial command 'x11x x<tab>' completion does not search in the correct
place. I would need to 'pre-evaluate' the 'x11x' macro to get it's new
PATH and glob THEREIN! OK, getting that PATH might be done simply by
'x11x echo "$path"' as I asume there is an evaluate in 'x11x'.
BUT HOW TO 'first change the PATH, then glob on the new PATH' ?
Thanks for a HINT , your's Stucki
Christoph von Stuckrad * * | talk to | <stucki@math.fu-berlin.de> \
Freie Universitaet Berlin |/_* | nickname | ...!unido!fub!leibniz!stucki|
Fachbereich Mathematik, EDV |\ * | 'stucki' | Tel:+49 30 838-7545{9|8} |
Arnimallee 2-6/14195 Berlin * * | on IRC | Fax:+49 30 838-5913 /
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to complete commands on a different/generated PATH ?
1996-08-28 15:22 How to complete commands on a different/generated PATH ? C. v. Stuckrad
@ 1996-08-28 17:49 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1996-08-28 17:49 UTC (permalink / raw)
To: C. v. Stuckrad, zsh-users
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"
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-08-28 18:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-28 15:22 How to complete commands on a different/generated PATH ? C. v. Stuckrad
1996-08-28 17:49 ` Bart Schaefer
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).