# How to install Oh My Zsh on a Raspberry Pi

Set up a more useful, prettier and cooler terminal on your Raspberry Pi

Because I run my Raspberry Pi’s headless (see my earlier post on how I set that up) I spend most of my time in the terminal. The default terminal works pretty well, but it can work better. I always install Oh My Zsh, a framework to manage Zsh (Z shell is the shell used) configuration. Oh My Zsh can help you install plugins (for autocomplete or history for example), but also help with theming your terminal.

NB, Oh My Zsh can be installed on any Zsh shell, I also use it on my Mac’s.

First things first, before we get start, first we need to make sure our Raspberry Pi is up to date:

sudo apt update


## Switch to Zsh as a shell

By default the Raspberry Pi uses Bash as its shell. Let’s first switch from bash to Zsh:

sudo apt-get install zsh

chsh -s /bin/zsh

If you restart your shell now, it will ask to configure your Z shell. We won’t do that just yet, so choose q to quit and do nothing.

## Install Oh My Zsh

NB: The instructions below are correct at the time of writing, but you can always double check the readme of the Oh My Zsh project itself.

To install Oh My Zsh:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" This will download the install script (install.sh) and execute it. If you want to see what this install script actually does, you can do wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh sh install.sh ## Customize your Oh My Zsh I will share my preferred Oh My Zsh configuration below, but this is very personal. I like to expand my prompt with all kinds of information (time, account used, server user, git status etc). I also use a couple of useful plugins. However, do check out the plugins and themes available, there is something for nearly every use case! ### My theme: Powerlevel10K As a theme I like to use Powerlevel10K. I chose this theme because it is very ease to configure and offers great out of the box features. To install: git clone --depth=1 https://github.com/romkatv/powerlevel10k.git${ZSH_CUSTOM:-\$HOME/.oh-my-zsh/custom}/themes/powerlevel10k 

Open the Zsh settings (which can be found in ~/.zshrc):

nano ~/.zshrc

Find the line with ZSH_THEME= and set this to:

ZSH_THEME="powerlevel10k/powerlevel10k"

Save and close the file with CTRL+Q, Y and enter.

To make it work, you also need to install a font. How this works differs on each OS, so check the Powerlevel 10K documentation.

Restart your shell and you should enter the Powerlevel10K configuration wizard. This will help you set up the look and feel of your shell. If the configuration wizard does not automatically start, you can use p10k configure.

After running through the configuration wizard, you can customize the setup more by editing the Powerlevel10K configuration file, using nano ~/.p10k.zsh. This file has a lot of comments to explain how to change it, so it shouldn’t be too difficult.

### My preferred plugins

To add plugins you need to open your Zsh configuration (nano ~/.zshrc) and find the plugins area. You can add a new plugin by adding a line with the name of your new plugin. Do check the readme of the plugin you want, some plugins need to be installed first. If a plugin is not installed correctly, you will get an error when the configuration is reloaded (for example by restarting the shell).

1. Screenshot of my plugins area in my Oh My Zsh config (~/.zshrc)

#### git

Git is enabled by default. I use Git for all my repo management, so I leave this enabled. It offers short cuts and some useful functions, like current_branch to return the current branch. I believe this is also used to display git information in the prompt.

#### history

History makes it easier to use the history command, to search your command line history. I use hsi <term> the most to search my history for a specific term (it aliasses history | grep -i).

#### common-aliases

Common aliases does exactly what it says on the tin, give aliases to commonly used commands. I especially use la to view the contents of a directory a lot.

#### zsh-autosuggestions

Zsh Autosuggestions is a plugin that needs to be installed (check the instructions at the link). After installation this plugin will suggest an auto complete. You can keep typing (to narrow it down), press arrow right to complete, or arrow up to cycle through all possible suggestions. This plugin is responsible for me never really remembering commands because I always autocomplete.

#### zsh-syntax-highlighting

Zsh Syntax Highlighting is also a plugin that needs to be installed. After installation this will highlight the syntax of the command on the prompt, which makes it easier to review a command for errors.