Comparing the advantages of zshell over bash shell in Linux

Comparing the advantages of zshell over bash shell in Linux

Admins using bash shell might want to take a closer look at zshell, or zsh. With its likeness to bash and its enhanced features, zsh is gaining attention in the Linux community.

So what is different about zsh? First, zsh is a lot like bash with its similar feel and functionality. But, there are some enhancements that make zsh an interesting option. The following is a Thunderdome-style comparison of zsh and bash on a Linux server: 

Zsh enhancements: Tab completion and typo correction
Admins used to bash tab completion will find the enhanced capabilities in zsh impressive. These include presenting auto-completion command options in a menu that is able to be scrolled through using the arrow keys. For example, typing the following commands will provide a list of the potential command line flags:

$ ls -

Or,

$ rm -

To select a specific process to kill, a list of processes is available  with  the kill command.

Another feature is in the built-in pager, which provides a shortcut to the less command. To access it, type:

$ <filename

This is the same as running less filename on the command line.

For clumsy typists, a typo correction feature is available. For example, if an incorrect command is entered, zsh prompts a correction:

$ lls

zsh: correct 'lls' to 'ls' [nyae]?

To fix it, type y and

    Requires Free Membership to View

    When you register, my team of editors will also send you resources covering Linux administration and management; integration and interoperability between Linux, Windows and Unix; securing Linux and mixed-platform environments; and migrating to Linux.

    Margie Semilof, Editorial Director

    By submitting your registration information to SearchEnterpriseLinux.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchEnterpriseLinux.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

correct the command to ls, and then it’s ready to run.

Other options are useful as well. The n option declines to correct the command, a aborts the command, and e pops up the command line for editing. This auto-correction also works for command line flags and file names, including esoteric items like correcting invalid Git branch names.

Get started using zsh
To quickly get started with zsh, make use of Robby Russell’s collection of zsh themes, functions and tools prepackaged as “Oh My Zsh.” It can be installed via Russell’s installation script, which changes the shell to zsh:

$ wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

Manual zsh installation instructions are also available, requiring users to clone the Git repo and copy in the draft .zshrc template.

The “Oh My Zsh” repository contains a collection of themes and functions for a ready-made zsh environment to build on and change. It also comes with an uninstall script for easy removal:

$ uninstall_oh_my_zsh

The zsh shell comes with some excellent documentation and the zsh reference card. Online resources on sites like GitHub show example .zshrc files—the zsh equivalent of the .bashrc file—and can provide examples of how to customize zsh or examples of cool tips and tricks to enhance your command-line experience.

Some of zsh’s features are available with bash, but they are a lot more complex to set up and configure on bash, explaining why people have multi-page .bashrc files. If you’re heavy user of the shell, zsh may be an attractive alternative to bash. It’s quick and easy to get started using, and delivers some important features that make interacting with the shell a lot more fun.

ABOUT THE AUTHOR: James Turnbull is head of Operations at Puppet Labs. He is a former IT executive in the banking industry and author of five technology books, including the just released Pro Puppet, as well as Pulling Strings with Puppet and Pro Linux System Administration. James has been involved in IT Operations for nearly twenty years and is an advocate of open source technology.

This was first published in June 2011

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.

    Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.