Zsh is a Unix interactive shell with built-in scripting language that’s particularly suitable for administration of Unix and Unix-like systems. The shell is bash-like in a number of ways, making it easy to get started with for newcomers, and the scripting language has a clean syntax and powerful features that let you take control of local and remote systems alike without the language getting in your way.

In particular the string expansion, file and directory globbing and clean syntax for iterating over lists make it a good fit for systems scripting and control of multiple machines. It comes already installed in a vast number of popular Linux and BSD-based distributions, including Apple OS X. If you find it’s not installed then it’s usually just a quick package management command away.

Being bash-like, many simple bash scripts will run without issue via zsh, and those that don’t usually only require a minimal porting effort. Scripting from scratch is where its power lies though, and we’ll get into that quite a bit in this article series.

On top of the powerful scripting language and bash similarities, the interactive shell has one compelling feature for systems administrators: multi-line, multi-area prompts. Prompts in zsh, with a minimum of configuration, can reside on the left and right of the screen and span multiple lines. With full control over colours and support for syntax highlighting, zsh gives you a truly useful prompt that’s trivially context-aware, giving you at-a-glance information about the running environment you find yourself in.

If you have a multitude of systems to look after you can configure the prompt to make it acutely aware what machine you’re on, which user you currently are, and whereabouts in the directory hierarchy you find yourself. If you’ve configured it properly, issuing ‘pwd’, ‘whoami’ or ‘hostname’ should be a thing of the past.

Lastly, it’s easy to configure and there’s a wealth of information online, so learning more about zsh and its power, as you get to know it, is easy and fun. Let’s get stuck in with the scripting language with a view to working with multiple machines over SSH, and we’ll cover the prompt in a followup article.

This article assumes some familiarity with shell scripting and basic shell operation.
Continue reading