Oh My Zsh

1 minute read

Oh My Zsh

1 Installation

sudo apt install zsh
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

2 Plugins

2.1 Zsh Syntax Highlighting

This plugin provides syntax highlighting for the commands of shell zsh.

Installation

# Git clone this repository in plugins directory of oh my zsh.
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# Activate this plugin in ~/.zshrc.
plugins=( [plugins...] zsh-syntax-highlighting)

# Restart zsh.

Highlighters

Syntax highlighting is done by pluggable highlighters:

Activate Highlighters
# Add this variable to .zshrc.
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main ...)

By default, this variable is unset and only the main highlighter is active.

Extra Highlighters
Installation

Download the highlighter to the ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters. And add the name of highlighter to the variable ZSH_HIGHLIGHT_HIGHLIGHTERS.

2.2 Colored Man Pages

This plugin adds color to man pages.

2.3 Colorize

This plugin provides color highlighting for file contents of over 300 supported languages.

Installation

# This plugin needs python package pygments to be installed.
conda install pygments

plugins=(... colorize)

Style

# Change the highlighting style with the environment variable.
ZSH_COLORIZE_STYLE="colorful"

Usage

ccat <file>

3 Themes

3.1 Add Custom Themes

Put the theme file ended with .zsh-theme in the theme folder.

The basename of the file is the name of the theme.

$ZSH_CUSTOM
- themes
  - theme.zsh-theme

3.2.1 Spaceship

Requirements
Installation
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt" --depth=1

ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme" 

FAQ

1 Change default shell.

2 Remove ‘(base)’ of anaconda in the prompt.

# Add this command to the end of .zshrc
PROMPT=$(echo $PROMPT | sed 's/(base) //')

Updated: