Zsh is a terminal for UNIX systems that can be tuned to help you do more work with less effort. In this article I will show you some things that are useful to me.
Usually all the Linux distributions used bash as a default terminal, but there are a lot of other terminals like zsh, csh,tcsh. Most of the time I used Linux I used the default terminal but I tried other terminals and discovered that I like zsh more than bash. You can try another terminal without configuring it as your default terminal, just install the zsh package and execute the zsh command.
Oh my zsh
On this article I used a framework for zsh called oh my zsh that extends the default zsh adding plugins and themes. You can easily install with one command:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Configuration
Plugins
When the zsh starts the terminal, reads the .zshrc file located on the root of your home directory.
The first parameter of configuration that I use is the oh my zsh plugins:
plugins=(
git
python
pip
virtualenvwrapper
)
This enables the following plugins:
- git: This is my favorite one,it adds a lot of alias to manage the git, you can check them here. Also , if you are on a git directory indicates if there are unstashed files.
- python: Like git it adds some useful alias
- pip: Adds cache on the available pip packages
- virtualenvwrapper: Auto activates the virtualenv when you cd in a directory that have the same name as an existing virtualenv
Theme
On oh my zsh you can select the theme of your terminal. In my case my favorite is agnoster. You can set it like this:
ZSH_THEME="agnoster"
If you wan to explore the available themes you can find the list here
Alias
On zsh, like in other terminals you can set an alias to shortcut a command. Mine are these:
alias p="ipython3"
alias s="ssh"
These are two applications that I use very often so in this way I can do “s 192.168.1.22” and enter to another machine.
In the case of python,it is because I use the ipython to do quick calculations or test code
CDPATH
When using WSL navigating to different folders can be tedious and repetitive because you are always typing /mnt/c… . To avoid repeating this you can configure the CDPATH variable
CDPATH is a variable that you can use to indicate to the shell where to check when you change of directory. I started using a hash, that is like an alias of a folder, but after I discovered CDPATH that is far better. I have it configured like this:
typeset -path cdpath
setopt auto_cd
cdpath=(/mnt/c/)
On a Linux machine I use the CDPATH with the source directory to move quickly to my source code. You can add multiple directories separated by spaces