Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "Fallback" alias/function in zsh
- X-seq: zsh-users 1966
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: Paul Moore <gustav@xxxxxxxxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxxxxxxx
- Subject: Re: "Fallback" alias/function in zsh
- Date: Tue, 8 Dec 1998 15:50:32 -0800
- In-reply-to: <19981208220443.A180@xxxxxxxxxxxxxxxxxxxx>
- References: <19981208220443.A180@xxxxxxxxxxxxxxxxxxxx>
On Dec 8, 10:04pm, Paul Moore wrote:
> Subject: "Fallback" alias/function in zsh
>
> Is it possible to define a function which gets used whenever zsh's
> normal alias/function/builtin/path lookup fails?
In 3.1.5, there's the preexec() function, in which you could do something
like this:
function preexec() {
command=("$@")
}
function precmd() {
(($?)) && CMD /C "$command[@]"
}
That means, before executing the command, save it in $command; then, after
executing it (and just before printing the prompt) if the exit status was
nonzero, attempt to execute the command with CMD /C.
This will do unusual things when you execute compound commands (separated
with ; && || etc.) and won't work for backgrounded commands (&) but should
do what you want for simple commands typed at the prompt.
Of course, 3.1.5 isn't ported to Windows yet ...
Messages sorted by:
Reverse Date,
Date,
Thread,
Author