Admins using bash shell might want to take a closer look at zshell, or zsh. With its likeness to bash and its enhanced...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
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 -
$ 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:
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:
zsh: correct 'lls' to 'ls' [nyae]?
To fix it, type y and 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:
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.