ZSH tricks

ZSH logoFor a while now I’ve been wondering how to do the equivalent of jot (which generates a list of numbers) in ZSH. It’s pretty obvious that ZSH could do such a thing, but how? Jot isn’t installed by default, and I am lazy. Lazy enough to never look into it.

For a change, I did. Success! Here is one way to do it, which is sort of elegant:
while (( i++ < 10 )) { echo i is $i; }
Do note the remarks on the above link: playing around with the syntax might kill it quickly.
Using repeat might be neater, but that's only when you just need to iterate (and not keep track of the iteration).

Comments are closed.