Oh My Zsh shell op macOS configureren

De vergelijking tussen een standaard bash shell en zsh. Functies zoals autosuggesties gebaseerd op geschiedenis en het tonen van de huidige git branch en pyenv omgeving maken het leven een stuk eenvoudiger.
Tijd besteden aan het configureren van je shell loont echt in productiviteit. Ik ben erg gecharmeerd van zsh1, en met de juiste plugins kun je de goede functies van fish2 nabootsen, wat ook een goede shell is. Heb je hier nog nooit van gehoord? Maak je geen zorgen. Ik zal de stappen doornemen om tot de setup te komen zoals te zien is in de schermafbeelding hierboven.
Step 1: Installeer brew
We beginnen met het installeren van brew3, de beste package manager voor macOS. Die hebben we in latere stappen nodig om een andere terminal en zsh te installeren. Open de Terminal-app op macOS en voer het volgende commando uit:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Als je de vereiste Xcode Command Line Tools nog niet hebt, dan zal brew deze voor je installeren. Druk op return om de installatie te starten.
Step 2: Installeer iTerm2
Een terminal is het omhulsel van een programma dat een shell draait. Hoewel de standaard Terminal-app op macOS vrij goed werkt, geef ik de voorkeur aan iTerm24. Het biedt gesplitste weergaven, betere zoek- en plakgeschiedenis en meer. Het wordt ook voortdurend verbeterd, terwijl de Terminal-app zelden updates krijgt van Apple.
Nu we brew geïnstalleerd hebben, kunnen we ons afmelden voor de telemetrie verzameling5, het vervolgens updaten en dan iTerm2 installeren:
brew analytics off
brew update
brew install --cask iterm2
Sluit na de installatie de Terminal-app en ga verder in de zojuist geïnstalleerde iTerm.
Step 3: Installeer zsh en Oh My Zsh
We’re now ready to install zsh, again using brew:
brew install zsh
After zsh is installed, we’ll install Oh My Zsh6, which is a framework for configuring zsh with plugins and themes. Install it by running:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Step 4: Install Powerlevel10k and plugins
Installing themes and plugins in Oh My Zsh is usually done by cloning the repositories into the ~/.oh-my-zsh/themes
and ~/.oh-my-zsh/plugins
folders. Run the following commands to install the Powerlevel10k7 theme and zsh-autosuggestions8 and zsh-syntax-highlighting9 plugins:
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Step 5: Update zsh configuration
We must now update the ~/.zshrc
configuration file with this theme and plugins. Open the file in your favourite editor (for example, by running nano ~/.zshrc
), and modify the following lines:
ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
Step 6: Configure Powerlevel10k
Now the fun part starts, it’s time to configure Powerlevel10k! Restart the terminal. The configuration wizard below should then appear. In case you don’t see it, you can start it manually using p10k configure
.

The first step of the Powerlevel10k theme configuration wizard.
In the first step, it will ask if the Meslo Nerd Font should be installed. Answer with Yes, as this font contains many icons that we will be using. After the font is installed, restart iTerm2 once more, so that it is loaded.
In the next steps, the wizard will double check if the font is rendered correctly. Answer these questions, and if everything looks all right, you will get to the Prompt Style step. Select the Classic prompt style (option 2) here.

Select the Classic prompt style (option 2).
For the remaining steps you can go with my recommended settings below. You can reconfigure the theme at any time, so feel free to try out different options.
- Character Set:
- Unicode (option 1)
- Prompt Colors:
- Light (option 2)
- Show Current Time:
- 24-hour format (option 2)
- Seperators:
- Angled (option 1)
- Prompt Heads:
- Sharp (option 1)
- Prompt Tails:
- Flat (option 1)
- Prompt Height:
- One line (option 1)
- Prompt Spacing:
- Compact (option 1)
- Icons:
- Many icons (option 2)
- Prompt Flow:
- Concise (option 1)
- Enable Transient Prompt:
- No (n)
- Instant Prompt Mode:
- Verbose (option 1)
After the settings are applied, you should see the Powerlevel10k theme in action. Only one step remaining.
Step 7: Apply iTerm2 color preset
I like to align my terminal color preset with the one that I use in my code editor(s). In my case this is the One Dark color preset. Save the One Dark.itemcolors color preset to your computer.
In iTerm2, open the Preferences dialog, navigate to Profiles and open the Colors tab. In the Color Presets… dropdown, import the file from above, and apply it.

Import the One Dark color preset in iTerm2 and apply it.
Now we’re done, enjoy your new shell! The zsh-autosuggestions plugin will display previously used commands in gray, and you can use the ↑ and ↓ keys to navigate through these options. You can have a look at the plugins10 that are bundled with Oh My Zsh. Be careful though, as enabling too many plugins can slow it down.

The final result after applying the steps in this guide.