From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28612 invoked from network); 7 Oct 1999 16:11:15 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 7 Oct 1999 16:11:15 -0000 Received: (qmail 23897 invoked by alias); 7 Oct 1999 16:10:45 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2663 Received: (qmail 23889 invoked from network); 7 Oct 1999 16:10:44 -0000 From: "Bart Schaefer" Message-Id: <991007161032.ZM27181@candle.brasslantern.com> Date: Thu, 7 Oct 1999 16:10:31 +0000 In-Reply-To: <19991007153845.A3241@vin.ens-lyon.fr> Comments: In reply to Vincent Lefevre "paths for filename arguments" (Oct 7, 3:38pm) References: <19991007153845.A3241@vin.ens-lyon.fr> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-users@sunsite.auc.dk Subject: Re: paths for filename arguments MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 7, 3:38pm, Vincent Lefevre wrote: } Subject: paths for filename arguments } } $ lesspath=(~/text ~/doc) } $ less less:blah } } should make zsh search for file "blah" in the working directory, and } if it is not there, it should be searched in ~/text, then ~/doc. Before } executing less, zsh should replace "less:" by nothing or the correct } path element. You can do this with a shell function wrapper around the commands that you want to have this behavior, as long as you're willing to have the "functionargzero" option set. pathmagic=(less more vi) # put all such commands in this array function $pathmagic { integer i=0 local file search while ((i++ < $#)); do if [[ $argv[i] == $0\:* ]]; then eval 'search=(. $'$0path ')' for file in $^search/${argv[i]#$0\:}; do if [[ -f $file ]]; then argv[i]=$file break fi done fi done command $0 "$@" } Now each of the commands named in the `pathmagic' array will recognize a $path-style variable prefixed with its name (lesspath, morepath, vipath, etc.) and will convert arguments of the form command:file into files in the corresponding path. Fixing it so that vi less:foo more:bar also works, is left as an exercise for the reader. You could of course also do this with completion, but then the expanded forms appear in the history so history references won't track changes to the path variables. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com