From: "Benjamin R. Haskell" <zsh@benizi.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Command not found handler for non-searched commands?
Date: Sun, 29 Apr 2012 12:22:16 -0400 (EDT) [thread overview]
Message-ID: <alpine.LNX.2.01.1204291213180.27115@hp.internal> (raw)
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
next reply other threads:[~2012-04-29 16:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-29 16:22 Benjamin R. Haskell [this message]
2012-04-29 16:55 ` Benjamin R. Haskell
2012-04-29 17:00 ` Benjamin R. Haskell
2012-04-29 17:01 ` Benjamin R. Haskell
2012-04-30 1:34 ` Benjamin R. Haskell
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=alpine.LNX.2.01.1204291213180.27115@hp.internal \
--to=zsh@benizi.com \
--cc=zsh-users@zsh.org \
/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).