Oh-My-Zsh Configuration Guide for MacOs Terminal

Zsh?

Oh-My-Zsh is a framework for Zsh, the Z shell.

Oh-my-Zsh configuration turned out to be not so straight-forward with instructions being scattered all over, so I decided to gather it all in one place.

Follow the steps to set up and configure oh-my-zsh in your terminal and customize it by adding additional plugins like docker commands completion, syntax highlighting and zsh-completions.

Also feel free to use my current working .zshrc file for reference and adjust it according to your own needs.

Step 1: Install Zsh

brew install zsh

What is Homebrew?

It is a command-line tool that helps you install open source command line utilities with a one liner.

If you don’t have it installed yet, type the command below in your terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install and set up zsh as default

If necessary, follow these steps to install Zsh:

-Verify installation by running zsh — version. Expected result: zsh 5.1.1 or more recent.

- Make it your default shell: chsh -s zsh

**Note** that this will not work if Zsh is not in your authorized shells list (/etc/shells) or if you don’t have permission to use chsh. If that’s the case you’ll need to use a different procedure.

- 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.

- Test with $SHELL — version. Expected result: ‘zsh 5.1.1’ or similar

Step 2: Install Oh-My-Zsh

In terminal type the following command:

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

Step 3: Configure Oh-My-Zsh

You can configure oh-my-zsh settings just by opening ~/.zshrc in any text editor.

I used VSCode to open and view the ~/.zshrc file:

code ~/.zshrc

Step 4: Install Plugins

You can find various themes and plugins here:

Themes: https://github.com/robbyrussell/oh-my-zsh/wiki/themes

Plugins: https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins

I found few plugins very useful for my daily job:

Both zsh-completions and zsh-syntax-highlighting can be installed with brew.

brew install zsh-syntax-highlighting==> Downloading https://homebrew.bintray.com/bottles/zsh-syntax-highlighting-0.6######################################################################## 100.0%==> Pouring zsh-syntax-highlighting-0.6.0.mojave.bottle.tar.gz==> CaveatsTo activate the syntax highlighting, add the following at the end of your .zshrc:source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zshIf you receive "highlighters directory not found" error message,you may need to add the following to your .zshenv:export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=/usr/local/share/zsh-syntax-highlighting/highlighters==> Summary🍺  /usr/local/Cellar/zsh-syntax-highlighting/0.6.0: 25 files, 130.5KB

Syntax Highlighting Setup Steps

  • Simply clone this repository and source the script:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.gitecho “source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh” >> ${ZDOTDIR:-$HOME}/.zshrc
  • Then, enable syntax highlighting in the current interactive shell:
source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  • If git is not installed, download and extract a snapshot of the latest development tree from:
https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz

.zshrc file configuration:

⚠️ Note that the source command must be at the end of ~/.zshrc.

Some other useful commands

  • to reload your shell:
exec $SHELL -l
  • in order to re-read .zshrc configuration:
source ~/.zshrc

In case if you might want to uninstall oh-my-zsh…

uninstall_oh_my_zsh

To manually uninstall:

rm -rf ~/.oh-my-zshrm ~/.zshrccp ~/.zshrc.pre-oh-my-zsh ~/.zshrcsource ~/.zshrc

Everything is unknown until it’s known. Self-learner.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store