In order to have more productivity under my environment, as a command line centric guy, I started three years ago to use zsh as my default shell. And for who never tried it, I would like to share my personal thoughts.
What are the main advantages?
- Extended globbing: For example, (.) matches only regular files, not directories, whereas az(/) matches directories whose names start with a and end with z. There are a bunch of other things;
- Inline glob expansion: For example, type rm *.pdf and then hit tab. The glob *.pdf will expand inline into the list of .pdf files, which means you can change the result of the expansion, perhaps by removing from the command the name of one particular file you don’t want to rm;
- Interactive path expansion: Type cd /u/l/b and hit tab. If there is only one existing path each of whose components starts with the specified letters (that is, if only one path matches /u/l/b*), then it expands in place. If there are two, say /usr/local/bin and /usr/libexec/bootlog.d, then it expands to /usr/l/b and places the cursor after the l. Type o, hit tab again, and you get /usr/local/bin;
- Nice prompt configuration options: For example, my prompt is currently displayed as tov@zyzzx:/..cts/research/alms/talk. I prefer to see a suffix of my current working directory rather than have a really long prompt, so I have zsh abbreviate that portion of my prompt at a maximum length.
The Z shell is mainly praised for its interactive use, the prompts are more versatility, the completion is more customizable and often faster than bash-completion. And, easy to make plugins. One of my favorite integrations is with git to have better visibility of current repository status.
As it focuses on the interactive use, is a good idea to keep maintaining your shell scripts starting with
#!/bin/bash for interoperability reasons. Bash is still most mature and stable for shell scripting in my point of view.
So, how to install and set up?
sudo apt-get install zsh zsh-lovers -y
zsh-lovers will provide to you a bunch of examples to help you understand better ways to use your shell.
To set zsh as the default shell for your user:
chsh -s /bin/zsh
Don’t try to set zsh as default shell to your full system or some things should stop to work.
Two friends of mine, Yuri Albuquerque and Demetrius Albuquerque (brothers of a former hacker family =x) also recommended using https://github.com/robbyrussell/oh-my-zsh. Thanks for the tip.
How to install oh-my-zsh as a normal user?
curl -L http://install.ohmyz.sh | sh
$ZSH_THEME is set to “bureau” under my
$HOME/.zshrc. You can try “random” or other themes located inside
And, if you use Ruby under RVM, I also recommend to read this: