Life is short! Use Zsh!
First check if your system has zsh and what shell is your system is using.
1 | $ cat /etc/shells |
If your system has zsh already, we are fine. If not, you shall go to install zsh first.
https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH
1 | $ chsh -s /bin/zsh |
Then you can logout and open a new terminal.
1 | $ echo $SHELL |
Next, we are going to install oh-my-zsh. Check it on the github README, Basic Installation.
https://github.com/robbyrussell/oh-my-zsh
After install oh-my-zsh, we need to change the config ~/.zshrc
to make your zsh more powerful. I feel the most useful is auto-completion. Here is my personal zsh config.
1 | # Antigen: https://github.com/zsh-users/antigen |
You can directly copy it and use it. Also if you have some environment variables settings in your previous shell, for example bash. You may look at your bash config file, such as ~/.bash_profile
or ~/.bashrc
and copy them into your zsh config. You may feel it very convenient to directly add a source ~/.bash_profile
in your zsh config, but I suggest you do not do this.
Here is a problem I meet in my work. My work VM lost a lot of environment variables such as $JAVA_HOME when I switch to zsh, this is very strange because this environment variable is configured by IT and it should be automatically loaded despite which shell I am using.
I began searching and found it lives in a script in /etc/profile.d/
.
If you look at /etc/profile
, it will run the script in /etc/profile.d/
to load all the personal setups.
1 | for i in /etc/profile.d/*.sh ; do |
When you login, /etc/profile
should be started at first. However, zsh is unique, it will not load this. However, my colleague has never met this problem before. So we began searching why this happened. There must be a script zsh will run the scripts under /etc/profile.d
.
After hours, we found the key problem. In /etc/zshrc
, his file contains
1 | _src_etc_profile_d() |
However, my /etc/zshrc
does not have this! Why?
Because my company is still using Centos 6. And I used
1 | $ yum -y install zsh |
Its version still begins with 4. Now the zsh version would begin with 5. After I downloaded the zsh with version 5, I could find /etc/zshrc
has the function to load the scripts under /etc/profile
and my problem was solved.
Life is short! Why use Centos 6!