From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18609 invoked by alias); 11 Mar 2011 11:38:28 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15860 Received: (qmail 27538 invoked from network); 11 Mar 2011 11:38:25 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Fri, 11 Mar 2011 10:44:02 +0000 From: Peter Stephenson To: Zsh Users Subject: Re: possibly useful zsh_directory_name implementation Message-ID: <20110311104402.6a411b10@pwslap01u.europe.root.pri> In-Reply-To: References: Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.8 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.103.11.49] X-Scanned-By: MailControl A_10_80_00 (www.mailcontrol.com) on 10.68.0.113 On Fri, 11 Mar 2011 02:06:45 +0100 Mikael Magnusson wrote: > function zsh_directory_name () { >... > } > > With this, /home/mikachu/some/directory/somewhere% cd ~[/some], will > take you to /home/mikachu/some/, and cd ~[.foo] will take you to foo/ > in whatever parent directory has a subdirectory foo, for example it > could be /home/foo/. I've been meaning to add a zsh_directory_name hook, so you can have multiple functions implementing this and the function here would interact nicely with other functions that implemented naming without the "/" or "." at the start. However, I need to think about the consequences --- it's more complicated than the existing hooks. (Just to state the obvious, you can get a less controllable effect of this using cdpath, although I find life's a bit too complicated to rely on cdpath these days. My zsh_directory_name implements a hierarchical scheme where, for example, [p:c:p=main] specifies which Perforce client I'm using, which project within the client, and which private branch within the project. It might be interesting to generalise this to something configurable with associative arrays.) -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom