From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28895 invoked by alias); 27 Oct 2010 16:18:58 -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: 15506 Received: (qmail 3235 invoked from network); 27 Oct 2010 16:18:47 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at magma.ca does not designate permitted sender hosts) Date: Wed, 27 Oct 2010 11:45:18 -0400 From: Jean-Rene David To: zsh-users@zsh.org Subject: Re: Neat hash -d trick Message-ID: <20101027154518.GS11455@lefuneste.homelinux.org> Mail-Followup-To: zsh-users@zsh.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) * Nikolai Weibull [2010.10.21 18:40]: > I came up with this just now: > > for ((i = 1; i < 9; i++)); do > hash -d .$i=${(j:/:)${(l:2::.:)${(s::)${(l:i::.:)}}}} > done > > It allows you to write > > cd ~.4/dir > > which would cd to ../../../../dir, given that that directory exists. > > If someone could come up with a simpler expansion that would be sweet. Once, a long time ago, I bound "\C-k" to "cd .." and I never looked back. It's easy to type and easy to repeat. And with the current directory in the prompt (RPS1 in my case) it's very easy (and very fast) to go up high enough but no further in the directory tree (without having to count directories). Neat trick though... :-) -- JR