Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Command not found handler for non-searched commands?
- X-seq: zsh-users 17041
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Command not found handler for non-searched commands?
- Date: Sun, 29 Apr 2012 12:22:16 -0400 (EDT)
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
I use autocd quite a bit. And often the first thing I want to do when
starting a new project is to create a directory and cd into it. I tried
creating the following command_not_found_handler:
command_not_found_handler () {
local dir create
echo HEREIAM >&2
(( $# == 1 )) || return 1
[[ $1 == */* ]] || return 1
dir=$1
read -q "create?Create $dir [y/N]? " || return 1
mkdir -p $dir || return 1
cd $dir
}
But, it doesn't get called when I need it:
## when I don't need it:
$ fake-command-here
HEREIAM
zsh: command not found: fake-command-here
## when I do need it:
$ ~/tmp/one-off-project
zsh: no such file or directory: /home/bhaskell/tmp/one-off-project
I see from the description of how commands are found that it won't get
called when there's a slash in the command. Is there a way to force it?
Otherwise, is there another, easy way to accomplish my goal?
--
Best,
Ben
Messages sorted by:
Reverse Date,
Date,
Thread,
Author