zsh-users
 help / color / mirror / code / Atom feed
From: "Benjamin R. Haskell" <zsh@benizi.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Command not found handler for non-searched commands?
Date: Sun, 29 Apr 2012 12:55:07 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LNX.2.01.1204291251150.27115@hp.internal> (raw)
In-Reply-To: <alpine.LNX.2.01.1204291213180.27115@hp.internal>

On Sun, 29 Apr 2012, Benjamin R. Haskell wrote:

> 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:
>

Okay.  Different tack, different problem:

preexec {
   __last_command=$1
   # ... etc.
}

trap '
   local dir= create=
   set -- ${=__last_command}
   (( $# == 1 )) || return 1
   [[ $1 == */* ]] || return 1
   dir=$1
   read -q "create?Create $dir [y/N]? " || return 1
   mkdir -p $dir || return 1
   cd $dir
' ZERR

Now $dir ends up containing '~/tmp/one-off-project', with the '~' 
unexpanded.  Seeing as how the directory doesn't yet exist, I can't just 
glob it.  Is there a function to do just named-directory expansion?

-- 
Best,
Ben


  reply	other threads:[~2012-04-29 16:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-29 16:22 Benjamin R. Haskell
2012-04-29 16:55 ` Benjamin R. Haskell [this message]
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.1204291251150.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).