loading...

Installing and customizing oh-my-zsh on Ubuntu

nicoh profile image Nico H. ・2 min read

ZSH (or Z Shell), is an extended version of the default shell. It includes new features, themes and plugins.

We can install it from the default shell using:

$ apt install zsh
Enter fullscreen mode Exit fullscreen mode

Oh-my-zsh is a framework that runs on top of ZSH. If you want to understand it from a web example, it would be something like this: ZSH is Javascript and oh-my-zsh is React/Angular/Vue/etc.

From their site:

Oh My Zsh is a delightful, open source, community-driven framework for managing your Zsh configuration. It comes bundled with thousands of helpful functions, helpers, plugins, themes, and a few things (...)

We can simply install it with a one-liner. Via cURL:

$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Enter fullscreen mode Exit fullscreen mode

Or via Wget:

$ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
Enter fullscreen mode Exit fullscreen mode

We accept changing our default shell to zsh, enter our password and that's it:

installation_completed

Note: As you can see, the ~ symbol indicates that zsh is being used. But if we close the terminal and open it again, the default shell will be used.

We can now run '$ zsh' to enable it, or simply logout/login and the default shell will be zsh.

If the change didn't work and we still have the default shell running, run:

$sudo chsh -s $(which zsh) $(whoami)
Enter fullscreen mode Exit fullscreen mode

Customization

ohmyzsh comes with a lot of plugins and themes preinstalled. I'll be showing you how to customize it using my current preset.

First, we install powerline font to have support for icons in our terminal:

sudo apt install fonts-powerline
Enter fullscreen mode Exit fullscreen mode

Then, we change the default theme 'robbyrussell' to agnoster. This one is pretty common because it's optimized for git repository usage.

sudo nano ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

And change ZSH_THEME variable to ZSH_THEME="agnoster".

To remove the username and host from the prompt, modify:

sudo nano ~/.oh-my-zsh/themes/agnoster.zsh-theme
Enter fullscreen mode Exit fullscreen mode

And comment 'prompt_context' like below:

comment_prompt_context

If you followed the previous steps, you'd have something like this (using Solarized Dark theme for the terminal):

final

Discussion

pic
Editor guide
Collapse
eroberts profile image
Ethan Roberts

I highly suggest Antibody over Oh My Zsh. With Oh My Zsh adding any more than 3 plugins can make your shell take up to 10 seconds or more to load.

Antibody is a plug-in manager written in Go so that it loads the plugins simultaneously instead of one at a time and is significantly faster.

Collapse
nicoh profile image
Nico H. Author

Hi Ethan, thanks for your suggestion. Have you tried using Antibody to load oh-my-zsh plugins in the past?

Collapse
mcdennis11 profile image
mcDennis11

Precise and to the point. Thank you.

Collapse
mayronceccon profile image
Mayron Ceccon

I ♥️ zsh! I'm use um Fedora!