zsh-users
 help / color / mirror / code / Atom feed
* Neat hash -d trick
@ 2010-10-21 22:34 Nikolai Weibull
  2010-10-22  4:05 ` Bart Schaefer
  2010-10-27 15:45 ` Jean-Rene David
  0 siblings, 2 replies; 8+ messages in thread
From: Nikolai Weibull @ 2010-10-21 22:34 UTC (permalink / raw)
  To: Zsh Users

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.

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’t figure out a
way to include the loop in the expansion.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-10-27 16:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-21 22:34 Neat hash -d trick Nikolai Weibull
2010-10-22  4:05 ` Bart Schaefer
2010-10-22  7:28   ` Mikael Magnusson
2010-10-22  8:09     ` Julien Nicoulaud
2010-10-22  8:39     ` Jérémie Roquet
2010-10-22 10:29   ` Nikolai Weibull
2010-10-22 14:24   ` Oliver Kiddle
2010-10-27 15:45 ` Jean-Rene David

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).