From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7822 invoked by alias); 21 Oct 2010 22:34:15 -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: 15467 Received: (qmail 11958 invoked from network); 21 Oct 2010 22:34:13 -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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.214.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=ODYN+mW1zHYHsoLaj1214KizXcFOTdbyObonQeb/LAI=; b=wyaSB3O16cPnD7Tewk+w/8jHDJuJLpKJcy+jl9+W7GJaD67F41bwGmGfFSuxAwAO2s 1iyehpJ+AmivqNYh/yROZPes6c/CnWDGEjbL2rzJ3Yjoxj8o+Sz+xr7GUBlUaeEKksyO trorkdsLmrn31qMjIHDjWydMlHqw/L1rn/VCY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; b=gZ20fHH5cnWVNvUolqSoQ+gnrUnM4cyx7VZ8MV/cXsqw0OpAUUCM3opYt6JYRTsckS WPvAXyLSYT+Ayfo+M4vY9KqRMbk08KTrOq37m65PcLpf0E+YQ6bPFc6WiUvqC2PegbzD FM60cEiRU84EUZEyDVDhCnaDN5Cx9UPzwV5kQ= MIME-Version: 1.0 Sender: nikolai.weibull@gmail.com Date: Fri, 22 Oct 2010 00:34:09 +0200 X-Google-Sender-Auth: mM-54OOSfbNlsHPtppoX7dRLYZs Message-ID: Subject: Neat hash -d trick From: Nikolai Weibull To: Zsh Users Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I came up with this just now: for ((i =3D 1; i < 9; i++)); do hash -d .$i=3D${(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. What would be even sweeter is if someone would come up with a way to do this with only one call to hash -d without writing out all the expansions and can easily be parameterized. I couldn=E2=80=99t figure out = a way to include the loop in the expansion.