Zsh is a UNIX command interpreter like Bash and other shells.
Zsh also claims to have better scripting but I would never make my scripts for zsh only, because it does not come as a default when you install Linux or Windows for that matter.
It is the default on MAC though so there is quite a big potential.
So why do people replace Bash with Zsh?
I had to find out so I simply installed it from my CLI
Code: Select all
sudo pacman -S zsh
Nothing to it and since manuals are for chicken - I simply typed zsh in my terminal.
That lead me to a first install routine where I picked everything that was recommended basically - and that was it.
Easy! And since I had no clue what to do next I had to do a little reading
So I found out that I had to do a
Code: Select all
chsh -s $(which zsh)
to switch my user from bash to zsh.
Login out or restarting and loging back in and the bash should be replaced with zsh.
It was pretty obvious since the propmt had changed a bit
You can also do a
Code: Select all
echo $SHELL
To get a confirmation of the obvious.
The important file in zsh is ~/.zshrc which makes sense since the important file is .bashrc for Bash. It was set up for me by that first run prompting so I had a fully functional zsh.
One would think that I would have to read a lot of books and that none of my usual Terminal-habits where usable anymore, but that is not the case. The bash commands do work and I could pretty much go on like before.
And this is the great advantage of Zsh it does not fubar your precious habits but it adds some functionality.
Many of the functions that are highly praised on the internet are equally possible in Bash so it's "fantasticness" is exaggerated.
But one or two nice extras can be added.
Since I always put my aliases in a separate file (called .alias) I added this to
~/.zshrc
Code: Select all
if [ -f ~/.alias ]; then
. ~/.alias
fi
and restarted the shell with
Code: Select all
source ~/.zshrc
Now all my aliases did work and they do show up when I type alias.
If you have all your aliases in .bashrc then you can simply copy them into .zshrc and they will work like before.
I added some plugins that enables me to write the directory name and jumps to it:
Not cd Pictures but simply Pictures - lazynes is an art - I tell you
And I listed the available prompts with
Code: Select all
prompt -l
and picked fade.
You can check out any of the prompts listed by typing
Code: Select all
prompt redhat
So far it was not that different from bash.
Now the thing that impressed me a bit was the way I could autocomplete commands like systemctl or pacman.
I typed
Code: Select all
pacman -
Imagine I am a newbie and know that I have to type "pacman -" but do not know what switches to use. Here i can hit <TAB> and pick the option I need with <TAB> and hit enter.
If I type
Code: Select all
systemctl
and hit TAB I get all 149 commands that can be used with systemctl. Now that is a bit heavy and it works in bash too by hitting TAB twice.
But when I have some idea and write something like this:
Code: Select all
systemctl sta
and hit TAB then I have narrowed it down to two alternatives:
Code: Select all
start -- Start (activate) one or more units
status -- Show runtime status of one or more units
This does not work in bash. This zsh function works nicely with yum in Centos, and urpmi too (try "urpmi -" + <TAB>).
So here is my .zshrc you can simply copy it and put it in your ~/ and start zsh as described above and you are good to go without the first install routine (all my examples here are based on this .zshrc).
You may put your aliases in the file ~/.alias but you don't have to.
I also added the dirstack function where you can type
Code: Select all
dirs -v
you get your dir history and jump directly to your directory by typing cd and the number - this can be a time-saver.
Now try to hit <TAB> on
Code: Select all
cd /u/s/i
It will autocomplete every part one at a time until you are in /usr/share/icons or info or whatever you are looking for...
Try it - If you don't like it you can go back to bash.
A slight warning here though
Set your shell back to bash before you remove zsh:
Code: Select all
chsh -s /bin/bash berserk
This is how it goes in Arch based distros - make sure you have managed this before you remove zsh from your distro.
Restart your computer before your remove zsh and check that bash is back in your terminal - then you are good to remove zsh.
But since Bash is back why not keep zsh in case you want to play around with it again? In which case you would do a
Code: Select all
chsh -s $(which zsh)
...
So is this a "must have" a "need"?
Depending on your needs I am inclined to say no - but it is nice.
I have used this procedure on Centos 6.5, Manjaro and Openmandriva so it should be pretty universal.
On some commands I have gotten the error
~/.cache/zsh/dirs are missing.
That is easily fixed by creating zsh manually:
Code: Select all
cd .cachce
Code: Select all
mkdir zsh