Thursday, July 10, 2014

How and Why To Switch to Zsh from Bash


Ubuntu comes with Bash as its default "shell". So, when you're running `gnome-terminal` (the default terminal emulator) it actually sends the commands to '/bin/bash' which interprets your command and displays output.

What is the difference between shell, console, and terminal?

Zsh is an improvement on bash. It adds more functionality, and better ways of doing things.

Bash vs Zsh | /r/linux

Image from Oh My Zsh

Switching to zsh is a "do once, be grateful for ever" task thanks to Oh My Zsh.

As explained on Getting started with ZSH on Ubuntu (for technotards), you need to first install zsh.
sudo apt-get install zsh 
Then you can install Oh My Zsh
curl -L http://install.ohmyz.sh | sh
Change Shell
At the end of the Oh My Zsh installation script, there's a command to change the default shell to zsh (from bash, or any previous shell). But this might fail by not asking for a password. In case this happens, do this manually.
chsh -s `which zsh`
Important: Changing shell needs you log out and log in to take effect.

Configure
Zsh has a lot of configurations, and Oh My Zsh does these for us. Now you can configure Oh My Zsh!

Enable plugins
In .zshrc, change
plugins=(git)
to, say
plugins=(git common-aliases autojump python sudo)
With common-aliases, you can do `vim .zshrc` by `zshrc`.

Themes
Oh My Zsh comes with 137 themes. Set a random theme to load at startup by changing in .zshrc
ZSH_THEME="random"
Override plugins (optional)
The common-aliases plugin has "j" alias for jobs. Autojump uses "j" to jump directories. To resolve conflicts like these, just make your own custom version of the conflicting plugin. Like I copied '~/.oh-my-zsh/plugins/common-aliases' to '~/.oh-my-zsh/custom/plugins/common-aliases' and edited the 'common-aliases.plugin.zsh' in that to comment out the "alias j='jobs'"

Migrate .bashrc and .bash_aliases (optional)
If you had custom settings in '~/.bashrc' or '~/.bash_aliases' that you want to copy over, you can copy them to '~/.zshrc'

Alternately, you can create an Oh My Zsh plugin of your own by creating a *.plugin.zsh file in custom/plugins directory.

Enjoy (required)
Open a new terminal (Ctrl+Alt+T), and see a fresh terminal


If you like what you're reading, subscribe!

Get posts via email:

No comments :

Post a Comment

What do you feel?




One more time, subscribe via email: