Skip to content

Instantly share code, notes, and snippets.

@willianfalbo
Last active Nov 16, 2021
Embed
What would you like to do?
Install Zsh, Oh-My-Zsh, Fonts-Powerline & Plugins (Ubuntu 18.04+)

Install Zsh, Oh-My-Zsh, Fonts-Powerline & Plugins (Ubuntu 18.04+, MacOS)

Introduction

After following these steps, your terminal will look like:

1. Install Zsh

Zsh is a shell designed for interactive use, although it is also a powerful scripting language.

Run sudo apt install zsh

Verify installation by running zsh --version

Make it your default shell: chsh -s $(which zsh)

Log out and login back again to use your new default shell.

Test that it worked with echo $SHELL. Expected result: /bin/zsh or similar.

Reference: https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH

2. Install Oh My Zsh

Oh My Zsh is an open source, community-driven framework for managing your zsh configuration.

Requirements:

  • git should be installed (recommended v2.4.11 or higher)
  • curl should be installed for Ubuntu or Mac.

Run sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Inspect the install script by running:

$ curl -Lo install.sh https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
$ sh install.sh

Reference: https://github.com/ohmyzsh/ohmyzsh

3. Install Fonts Powerline

Fonts Powerline contains pre-patched and adjusted fonts for usage with the Powerline statusline plugin.

For Ubuntu:

Run sudo apt install fonts-powerline

For MacOS:

# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts

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

Run sudo nano ~/.zshrc and change ZSH_THEME variable to "agnoster" like below:

ZSH_THEME="agnoster"

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

sudo nano ~/.oh-my-zsh/themes/agnoster.zsh-theme

And comment 'prompt_context' like below:

build_prompt() {
  RETVAL=$?
  prompt_status
  prompt_virtualenv
  prompt_aws
  # prompt_context
  prompt_dir
  prompt_git
  prompt_bzr
  prompt_hg
  prompt_end
}

References:

https://github.com/powerline/fonts

https://dev.to/nicoh/installing-oh-my-zsh-on-ubuntu-362f

4. Install Zsh Plugins (Auto Suggestions & Syntax Highlighting)

zsh-autosuggestions

This plugin has the capability for command completion. It suggests commands based on your command history.

Navigate to the plugins folder and clone the git repository:

$ cd ~/.oh-my-zsh/custom/plugins
$ git clone https://github.com/zsh-users/zsh-autosuggestions
zsh-syntax-highlighting

This plugin has the capability to verify the correctness of your command.

Navigate to the plugins folder and clone the git repository:

$ cd ~/.oh-my-zsh/custom/plugins
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting

Finally, add both plugins to the plugins list. Run sudo nano ~/.zshrc and change it like below:

plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

Reference: https://medium.com/wearetheledger/oh-my-zsh-made-for-cli-lovers-installation-guide-3131ca5491fb

Have fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment