Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to intercept the "command not found" error in ZSH? I've seen this is possible in bash apparently, but I couldn't find anything about doing it in zsh.

share|improve this question
up vote 6 down vote accepted

There is; it's the same as in bash, you make a function named command_not_found_handler. It'll be passed all the arguments that were given in the shell

$ foobar baz
zsh: command not found: foobar
$ function command_not_found_handler() {echo "You tried to run $1 with arg $2";}
$ foobar baz
You tried to run foobar with arg baz
share|improve this answer
    
Oh. Well that's easy enough. Thanks =] – Falmarri Jan 3 '11 at 20:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.