Oh My Zsh Basic Setup & Installation Guide

Oh My Zsh Basic Setup & Installation Guide

This is a very brief summary of installing zsh + Oh My Zsh with proper font & basic plugins for the OMZ

Zsh & Oh My Zsh Installation

Zsh Installation Guide
Oh My Zsh Installation Guide

# Install Zsh
# For Mac
brew install zsh
# For Ubuntu
sudo apt-get install zsh
# For SUSE Linux
sudo zypper install zsh

# Change zsh as the default shell
chsh -s $(which zsh)

# Install Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Install Fonts

Oh My Zsh (especially with a theme like Powerlevel10k) requires font with specific font ligature & icons.

I’m currently using JetBrains Mono for my dev. environment. To be exact, patched version from the Nerd Font. They are not that differ in standard use-cases, but powerlevel10k does require some of glyphs (icons) that Nerd Font provides.
I highly suggest downloading both official & nerd font patched versions and use the official one as a fallback.

# For Mac
brew tap homebrew/cask-fonts
# JetBrains Nerd Font Mono
brew install --cask font-jetbrains-mono-nerd-font
# JetBrains Mono
brew install --cask font-jetbrains-mono

# For Window
# Manually download the font & unzip + install the font
# JetBrains Nerd Font Mono
https://github.com/ryanoasis/nerd-fonts/releases/latest/download/JetBrainsMono.zip
# JetBrains Mono
https://github.com/JetBrains/JetBrainsMono/releases/latest

# For Linux
# JetBrains Mono
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/JetBrains/JetBrainsMono/master/install_manual.sh)"
# It's a bit trickier for Linux to install/patch Nerd Font... Please check Nerd Font repo for more information.

Append JetBrains Mono after the JetBrainsMono Nerd Font Mono to the font-family setting of your choice of IDE or Terminal.

"fontFamily": "JetBrainsMono Nerd Font Mono", "JetBrains Mono",

Install Theme

Install the theme that you want. I personally moved from Pure theme to Powerlevel10k. (AFAIK, Powerlevel10k is faster than Pure theme and supports various options to personalize look & functions)

Powerlevel10k

Powerlevel10k is a theme for Zsh. It emphasizes speed, flexibility and out-of-the-box experience.

Check get started to find your best installation option.

  1. Clone this repository in oh-my-zsh’s themes directory:

    git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
    
  2. Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc.

OMZ Plugins

Any extension with :pushpin: attached are things that you MUST INSTALL for a better life.

autoupdate :pushpin:

Oh My Zsh plugin for auto-updating of git-repositories in $ZSH_CUSTOM folder

  1. Clone this repository in oh-my-zsh’s plugins directory:

    git clone <https://github.com/TamCore/autoupdate-oh-my-zsh-plugins> ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/autoupdate
    
  2. Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc):

    # file: "~/.zshrc"
    plugins=([plugins...] autoupdate)
    

The updates will be executed automatically as soon as the Oh My Zsh updater is started. Note that this will auto-update both plugins and themes found in the $ZSH_CUSTOM folder.

You may adjust how often omz checks for the update by adjusting the below line from the ~/.zshrc file.

# file: "~/.zshrc"
# Uncomment the following line to change how often to auto-update (in days).
export UPDATE_ZSH_DAYS=1

zsh-syntax-highlighting :pushpin:

Fish shell-like syntax highlighting for Zsh.

Check Installation Guide for detail.

  1. Clone this repository in oh-my-zsh’s plugins directory:

    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
    
  2. Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc):

    # file: "~/.zshrc"
    plugins=([plugins...] zsh-syntax-highlighting)
    

zsh-autosuggestions :pushpin:

Fish-like fast/unobtrusive autosuggestions for zsh.

Check Installation Guide for detail.

  1. Clone this repository in oh-my-zsh’s plugins directory:

    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
    
  2. Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc):

    # file: "~/.zshrc"
    plugins=([plugins...] zsh-autosuggestions)
    

zsh-completions :pushpin:

Additional completion definitions for Zsh.

Check git repo for detail.

  1. Clone this repository in oh-my-zsh’s plugins directory:

    git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
    
  2. Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc):

    # file: "~/.zshrc"
    plugins=([plugins...] zsh-completions)
    

Autojump :pushpin:

autojump - a faster way to navigate your filesystem

brew install autojump

fzf

fzf is a general-purpose command-line fuzzy finder.

brew install fzf

# To install useful key bindings and fuzzy completion:
$(brew --prefix)/opt/fzf/install

enhancd

A next-generation cd command with an interactive filter ✨

zplug "b4b4r07/enhancd", use:init.sh

exa

exa is a modern replacement for ls.

brew install exa

Others

  • Remove directory highlighting for WSL.

    LS_COLORS="ow=01;36;40" && export LS_COLORS #WSL dir colors
    
  • Add git aliases to the zsh.

    # file: "$ZSH_CUSTOM/git_aliases.zsh"
    # Create .zsh file in the $ZSH_CUSTOM folder.
    
    alias ga="git add"
    alias gaa="git add --all"
    alias gb="git branch"
    alias gba="git branch -a"
    alias gc="git commit"
    alias gca="git commit --amend"
    alias gcm="git commit -m"
    alias gco="git checkout"
    alias gd="git diff"
    alias glog="git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
    alias gm="git merge"
    alias gp="git push"
    alias gpl="git pull"
    alias gs="git status"
    
    # Gerrit
    gpg() {
        if [ -z "$1" ]; then
            BRANCH_NAME="$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)" | cut -d '/' -f2)"
        else
            BRANCH_NAME="$1"
        fi
        git push origin HEAD:refs/for/$BRANCH_NAME
    }
    
    gpgwip() {
        if [ -z "$1" ]; then
            BRANCH_NAME="$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)" | cut -d '/' -f2)"
        else
            BRANCH_NAME="$1"
        fi
        git push origin HEAD:refs/for/$BRANCH_NAME%wip
    }
    
    gpgready() {
        if [ -z "$1" ]; then
            BRANCH_NAME="$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)" | cut -d '/' -f2)"
        else
            BRANCH_NAME="$1"
        fi
        git commit --amend --no-edit
        git push origin HEAD:refs/for/$BRANCH_NAME%ready
    }