Why ZSH rocks

This post was published 5 years ago. It may be exremely outdated.

A couple of months ago I switched from Bash to ZSH. It took me a couple of minutes to know that I wouldn’t go back. These are some of the reasons that made me take that decision.

Auto-correction

ZSH auto-correction

ZSH auto-correction

Don’t you misspell commands sometimes? I do.

When ZSH can’t find the command I write it  offers me suggestions, usually being the command I actually wanted to use. For instance if we write clar it will suggest us clear, and it will probably be suggesting the right command.

Auto-completion

Browsing ZSH auto-completion results

Browsing ZSH auto-completion results

Bash auto-completion

Bash auto-completion

I find auto-completion extremely useful. Bash just lists the files in the current directory. ZSH changes its suggestions depending on the command written.

Let’s image we write kill, ZSH will show the list of running processes rather than the list of files in the current directory. If we write cd and press <tab> then ZSH will show us just the list of folders in the current directory.

This capability can be improved via plugins, making ZSH capable of auto-completing more precisely other programs.

Did I say that you can actually browse the list of suggested terms? Yes, you can.

Git plugin

What is nicer than having local branches auto-completion? Having remote origins and remote  branches auto-completion! And even more, you can show the current branch next to the current directory. Really nice features if you work with Git.

Other out-of-the-box useful features

Floating point math: I don’t always do math in the shell, but when I do, I need floating point numbers. To do floating point math in Bash you need external applications (bc, for instance). Floating point math works out-of-the-box in ZSH.

Expand variables: write a variable, press <tab> and see the value of that variable.

Global aliases: you can create aliases that work not just at the beginning. Pretty useful if you use to pipe outputs.

Easily enhanced

Want to show how much time took a command to finish? Piece of cake with ZSH, not so easy with Bash.

Want a better integration with, let’s say, Cloudapp? Take a look at the Cloudapp plugin, or check out some of the plugins available.

Of course, these are just some of the features I find most useful. If you use other ones feel free to tell about them in the comments.

Want to install it? Take a look at this guide, you only need a command!

Leave a Reply