My top 5 ZSH tips!

· Read in about 1 min · (213 Words)
zsh shell tips

Since reading this question on stackoverflow I’ve been intrigued by zsh, and looking at cool things it can do to make my life easier. I decided to jump on the top-n things bandwagon and publish a quick list of zsh bits I find really useful.

Here’s a quick list of my top five tips:

  1. Try using zsh’s awesome for loops:
    for file (prefix) $file:s/prefix/new_prefix/
    or if you want more than one command in the body, try:
    for file (prefix) {one; two; three}
  2. Use numerical ranges for operating on batches of files:
    will give you a range of values, which you can use in a loop (for n ({0..10})), and
    lets you match ranges of digits in filename globs.
  3. Use variable replacements to quickly munch filenames
    But alas, there’s no support for regular expressions in these.
  4. Try globbing instead of using find:
    will find all png files beneath your current directory. You can use this in a loop too:
    for f (**/*.txt) {echo $f}
  5. Use zsh-lovers”) to find out more. There’s far too much to zsh for me to be able to list it all here. My first stop is usually this man page, and it’s usually all I need.
  • Bonus! Google for zshrc config files. Try github and dotfiles first.