
History
The first version of Zsh was created in 1990 by a Princeton Student named Paul Falstad. The name “Zsh” supposedly comes from the connection ID of the Princeton professor Zhong Shao. The shell in itself was influenced from Bash, Ksh, and Tcsh: Zsh has a very powerful auto-completion functionality, along with recursive searches and a corrector included. And of course, the prompt can be defined according to the user’s wish. For all that, some consider Zsh as an extended Bourne Shell.Installation
Now that you know more about Zsh, let’s install it. For Ubuntu, the installation is fairly simple:sudo apt-get install zsh |
Once the package is installed, you can launch a Zsh Shell from any terminal via the command:
zsh |
sudo usermod -s /bin/zsh [user name] |
Usage
Zsh is very intuitive. At first, you should not notice any difference in behavior with Bash. However, a good way to spot the first feature is to type:rm – [tabulation key] |

Not only a command’s arguments, but also the ssh hosts presents in /etc/hosts, the possible targets for the “make” command, the manual pages, the files on a distant server, etc, all can be auto-completed by Zsh. And the auto-completion speed is also impressive.
You can also try type a wrong command like
gdit .zshrc |

If the correction does not work at first, it means that you haven’t activate it yet. To do so, simply type:
setopt correct |
- beep: to play a beep sound when an error occurs
- hist_ignore_all_dups: to prevent the same command from being recorded twice in the history
- auto_cd: to move to a directory just by typing its name (no need of the cd command anymore)
unsetopt [option] |
rm **/foobar |

The recursive operator can become really useful when searching a particular type of file. It is possible to use the combination of the “ls” command and a regex. A simple command like
ls **/*.mp3 |
Finally, let’s talk a little about the configuration of Zsh. As you know, it happens in ~/.zshrc. If you want to try some personalized prompts, Zsh comes with some saved themes. To see which one available, load the prompt system with
autoload -U promptinit |
prompt -l |
prompt [theme's name] |

If you have create plenty of aliases in bash, they won’t work in zsh. You have to port them over th the ~/.zsh file. The basic syntax is the same as Bash’s:
alias [alias' name]="[command]" |
alias -s mp3="mpg123" |
./song.mp3 |
alias -s tar="tar -xvf" |
Conclusion
Yes, Zsh and Bash are very similar, but zsh is more flexible that makes it more popular. Personally, I really appreciate the auto-completion feature and the alias for file extension. The above mentioned tips covered only a small part of what zsh can do. To find more about Zsh, I invite you to read the Archlinux wiki.What do you think of the Zsh Shell ? Have you tried another one? Do you have any question concerning the shells in general? Please let us know in the comments.
0 comments:
Post a Comment