From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-users@sunsite.auc.dk
Subject: Re: paths for filename arguments
Date: Thu, 7 Oct 1999 16:10:31 +0000 [thread overview]
Message-ID: <991007161032.ZM27181@candle.brasslantern.com> (raw)
In-Reply-To: <19991007153845.A3241@vin.ens-lyon.fr>
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
prev parent reply other threads:[~1999-10-07 16:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-07 13:38 Vincent Lefevre
1999-10-07 16:10 ` Bart Schaefer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=991007161032.ZM27181@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=zsh-users@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).