Nazarii Gudzovatyi

Errors should never pass silently.

Introducing ZSH.

Today I’d like to show you really usefull tool for working in command line I’ve discovered – ZSH. The Z Shell (zsh) is a power shell that is not often used by many Linux users. The reason for this is that most Linux distributions install, and make default, the bash shell. zsh is packaged for virtually every Linux distribution and installation on Ubuntu is simple made by running

bash
1
$sudo apt-get install zsh

After installation main configuration file .zshrc is located in you’r home directory. To make zsh as default shell run chsh command and include path to it’s executable:

bash
1
2
3
4
5
nazik@nazik-HP:~$ chsh
Password:
Changing the login shell for nazik
Enter the new value, or press ENTER for the default
    Login Shell [/bin/bash]: /bin/zsh

One of the great features of zsh is tab-completion; it also handles all the logistics of tab-completion and is extremely easy to implement, just by adding two lines to your ~/.zshrc file:

zsh
1
2
autoload -U compinit
compinit

The compinit function is what loads the tab-completion system by defining a shell function for every utility that zsh is able to tab-complete. By using autoload, you can optimize zsh by telling it to defer reading the definition of the function until it’s actually used, which speeds up the zsh startup time and reduces memory usage.

Also there is awesome plugin oh-my-zsh especially if you are often working with GIT repositories. To install this one run:

zsh
1
$wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

After installation you might need to reload you shell:

zsh
1
source ~/.zshrc

Each time you cd to you git repo it will show you branch you currently working on and whether you have uncommited local changes or not, if so it will show you gold sign: images Also there are a lot of themes for this plugin you can choose to use the other one then default “robbyrussell” theme. List of themes you can get at this link. To change to other one you need to edit you .zshrc file and reload shell.

You can also use aliases after adding it to your config file. To add time of command prompting to the right side of terminal append following line to your config file:

vim
1
RPROMPT=$'%{\e[1;34m%}%T%{\e[0m%}'

.

Comments