Tired of Your Shell? Try Zsh!

Article summary

I’ve been a Zsh user for several years now, and I figured that I would share my experience. For those who haven’t heard of it, Zsh is a command line shell, similar to Bash, but with many more built-in features. Many features of Zsh are available with Bash or other shells; however, Zsh does such a great job out of the box.

I will talk about a few features that I really like and that boost my productivity, but the best way to learn it is to try it out yourself. If you already use Bash or other similar shells, then the transition is quite easy, and I highly recommend it.

Positives

While I love customization, I also appreciate out-of-the-box features. Many Zsh features are available in other shells, but they take a large amount of time and effort to set up.

One of my favorite open-source projects is Oh-My-Zsh, an awesome community-driven Zsh customization framework. It comes with tons of plugins and themes which allow you to get started with a comprehensive environment in a matter of minutes. Truthfully, I’ve never used vanilla Zsh, so some of my fanboy-ism comes from the quality of Oh-My-Zsh. I highly encourage it. Starting fresh without any framework is definitely doable. I just haven’t had that experience.

The auto-completion in Zsh is absolutely fantastic. Not only does Zsh autocomplete file paths, like many other shells, it can also be easily programmed to complete other things as well. It automatically determines what to complete, based on the command. So, for example, git completion will be different than file (e.g. cd, cat, rm, less)  completion. The git plugins bundled in Oh-My-Zsh are great, and they allow for awesome tab-completion of files, commits, tags, branches, and more.

Zsh Git Autocompletion
Pressing tab brings up a list of options

Zsh Git Autocompletion
Pressing tab again allows you to navigate around the options with tab or the arrow keys

Zsh is forgiving when it comes to case sensitivity, so a “cd ~/documents/” would take me to ~/Documents/ as I would expect. Zsh can also support flag completion, so by pressing tab after a hyphen, it will show a list of available flags, with a short description of each.

Zsh Flag Autocompletion

Similar to auto-completion, the history in Zsh is quite nice. In addition to arrow cycling through the history, Zsh supports pattern matching. So, if I type “g” and press the up arrow, I will find all commands in my history that start with “g.” Likewise, if I type “git,” I will find all commands that start with “git.”

Negatives

As I mentioned earlier, I don’t use Zsh without Oh-My-Zsh. I’ve tried it without, but it didn’t feel like I was getting the same experience. It’s hard for me to argue that the shell is superior, when my judgement only comes from the framework I’ve used it with. I have no doubt that with enough time, I could customize any other shell to do the exact same things that I can do with Zsh. However, Oh-My-Zsh makes that customization a breeze, and I haven’t had to worry about that before.

Although there is a pretty activity community of Zsh users, it’s nowhere near the number of Bash users. Zsh is pretty similar to Bash though, so finding support isn’t hard.

Conclusion

I initially switched to Zsh because I was drawn to the quality of Oh-My-Zsh, the community around it, the out-of-the-box features, and the endless customization. The transition was easy, even though I had been a Bash user for several years before that. Regardless of your skill level with another shell, I would encourage you to try Zsh. You might be pleasantly surprised.

 
Conversation
  • Mattie Behrens Matt Behrens says:

    zsh is one of those things I need to get on-board with someday.

    “Zsh is forgiving when it comes to case sensitivity, so a ‘cd ~/documents/’ would take me to ~/Documents/ as I would expect.”

    This is actually not true—at least, not in the vanilla zsh I just tried. On a case-sensitive filesystem, it doesn’t work, as expected, but macOS defaults to a case-insensitive filesystem yet. And this is good; interactive cd’ing is a place where it would be convenient, but in a script it could create a serious problem.

    • Dan Kelch Dan Kelch says:

      Thanks for pointing that out Matt, I can forget what is standard and what is not.

      The option for case sensitivity is set with the command: zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'

  • Comments are closed.