iTerm2 + Oh My Zsh! + Powerlevel10K best terminal combination for Geeks!
Tags: productivity, terminal, macos, zsh
Published: 2018-09-25 14:37:53

---
title: iTerm2 + Oh My Zsh! + Powerlevel10K best terminal combination for Geeks!
published: true
tags: productivity, terminal, MacOS, zsh
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/mdlhui17i2k5dxd2nccr.png
series: macos-helpful-tips
---

There is a before and after listening to these letters together: ZSH. You may wonder: Why did not I hear about this before? D’oh!

[Oh My Zsh - a delightful & open-source framework for Z-Shell](https://ohmyz.sh/)

ZSH (Z Shell) it’s a real evolution, modernize terminal things with simple solutions. It can be used on GNU Linux and macOS, but I will teach you how to install and configure it on MacOS.

{% post https://dev.to/equiman/why-oh-my-zsh-is-so-cool-31gd %}

### Prerequisites

### Homebrew

Brew has his own classification. The inside brew can found the CLI app and utilities. Inside is cask all the application with Graphical Interface.

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

Add this lines to `~/.bash_profile` and/or `~/.zshrc` file:

```bash
# Brew
export BREW_HOME="/opt/homebrew/bin"
export PATH="$BREW_HOME:$PATH"
eval "$($BREW_HOME/brew shellenv)"
```

Run this commands on terminal:

```bash
eval "$(/opt/homebrew/bin/brew shellenv)"
source ~/.zshrc
source ~/.bash_profile
```

Restart your terminal, then update and upgrade brew sources:

```bash
brew tap homebrew/cask-fonts
brew update --force --quiet
brew upgrade
brew cleanup
```
<figcaption>https://brew.sh — usage: https://docs.brew.sh/FAQ</figcaption>

Run this command, and follow doctor recommendations:

```bash
brew doctor
```

### The Triplets of Belleville

> **WARNING:** I don’t want presume, but [iTerm2](https://www.iterm2.com/) + [Oh My Zsh!](https://ohmyz.sh/) + [Powerlevel10K](https://github.com/romkatv/powerlevel10k) it’s a lethal combination. You will not want to use another terminal later.

```bash
brew install --cask iterm2 

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

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

git clone https://github.com/nobeans/zsh-sdkman.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/sdkman
git clone https://github.com/zsh-users/zsh-autosuggestions.git ${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
git clone https://github.com/Pilaton/OhMyZsh-full-autoupdate.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/ohmyzsh-full-autoupdate

chsh -s /bin/zsh
```

Close the default terminal and open iTerm2.

#### Configuration

ZSH configuration file is located under `~/.zshrc`. Open with your favorite editor and set:

```bash
DEFAULT_USER="$USER"

ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(history)
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1

export LS_COLORS="rs=0:no=00:mi=00:mh=00:ln=01;36:or=01;31:di=01;34:ow=04;01;34:st=34:tw=04;34:pi=01;33:so=01;33:do=01;33:bd=01;33:cd=01;33:su=01;35:sg=01;35:ca=01;35:ex=01;32:"

ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor root line)
ZSH_HIGHLIGHT_PATTERNS=('rm -rf *' 'fg=white,bold,bg=red')

POWERLEVEL9K_INSTANT_PROMPT=quiet
POWERLEVEL9K_INSTANT_PROMPT=off

plugins=(
  brew
    command-not-found
    extract
    macos 
    git 
    github 
    gitignore 
    sdkman 
    history-substring-search 
    node 
    npm 
    volta
    vscode
    sudo
    web-search
    z
    zsh-autosuggestions
    zsh-syntax-highlighting
    ohmyzsh-full-autoupdate
)

# Z Plugin
if command -v brew >/dev/null 2>&1; then
  # Load rupa's z if installed
  [ -f $(brew --prefix)/etc/profile.d/z.sh ] && source $(brew --prefix)/etc/profile.d/z.sh
fi
source /opt/homebrew/etc/profile.d/z.sh

# Plugins
source /opt/homebrew/share/zsh-history-substring-search/zsh-history-substring-search.zsh
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
```

Add all the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) that you want or need inside `plugins=()` list, each one in a new line.

Open iTerm2 and after changing the value make sure to update your `~/.zshrc` file running the complete command:

```bash
source ~/.zshrc
```

#### Fonts

Download and Install Meslo and Nerd Fonts

```bash
brew install --cask font-meslo-lg-nerd-font
brew install --cask font-hack-nerd-font
```

Change it on `iTerm > Settings > Profiles > Text > Change Font` and select `MesloLGS NF`.

#### Visual Studio Code

If you want use ZSH as default terminal in Visual Studio Code, add this settings (`⌘ + ,`):

```json
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.fontFamily": "Meslo LG M for Powerline",
"terminal.integrated.defaultProfile.osx": "zsh",
```

#### Wizard

On the first run, Powerlevel10k configuration wizard will ask you a few questions and configure your prompt. 

If it doesn't trigger automatically, type `p10k configure`.

![Wizard](https://dev-to-uploads.s3.amazonaws.com/i/mtrv39dhe0f0b5pe2shs.gif)

Configuration wizard creates ~/.p10k.zsh based on your preferences. Additional prompt customization can be done by editing this file. It has plenty of comments to help you navigate through configuration options.

### Terminal (Bash)

macOS default terminal comes with version 3 and not going to update it because the newer version changes his license. Apple does not supply any software under the GPLv3.

Open default terminal and run this command in order to use an updated version:

```bash
brew install bash bash-completion
```

Add this line to `~/.bash_profile` file:

```bash
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
```

Open terminal and change `Terminal > Settings > General` on `Shell open with:` select `Command (complete path)` and set `/bin/bash` value.

With this configuration, now you can use ZSH on iTerm2 and Bash on default Terminal.

### Remove “Last login:”

For me, it's unnecessary and annoying the default “Last login:” message in the macOS terminal. Happily, it's easy:

```bash
touch ~/.hushlogin
```

### Become a ZSH Ninja!

Highly recommend taking this **FREE** course made by [@WesBoss](https://twitter.com/wesbos):

{% twitter 583629194837372929 %}

### CheatSheet (Key Shortcuts)

The common MacOS modifier keys are:

| Command | Control | Option | Shift |
| :-: | :-: | :-: | :-: |
| `⌘` | `⌃` | `⌥` | `⇧` |

By default, word jumps and word deletions do not work. To enable these, go to `iTerm > Settings > Profiles > Keys > Load Presets…` and select `Natural Text Editing`.

#### Basic Actions

| Shortcut | Function |
| --- | --- |
| `⌥` + `→` or `⌥` + `←` | Word jumps |
| `⌥` + `backspace` | Word deletion |
| `⌃` + `d` | Delete current character |
| `backspace` | Delete previous character |
| `⌃` + `-` | Undo |
| `⌘` + `backspace` | Entire line deletion |
| `⌘` + `k` | Clear entire screen |

#### Moving Faster

| Function | Shortcut |
| --- | --- |
| `⌃` + `a` | Move to the start of line |
| `⌃` + `e` | Move to the end of line |
| `⌥` + `f` | Move forward a word |
| `⌥` + `b` | Move backward a word |

#### Copy and Paste

| Function | Shortcut |
| --- | --- |
| `⌃` + `k` | Copy from cursor to the end of line |
| `⌥` + `d` | Copy from cursor to the end of word |
| `⌥` + `backspace` | Copy from cursor to the start of word |
| `⌃` + `w` | Copy from cursor to previous whitespace |
| `⌃` + `w` | Paste the last copied text |
| `⌥` + `y` | Loop through and paste previously copy text |
| `⌥` + `.` | Loop through and paste the last argument of previous commands |

#### Tabs & Windows

| Function | Shortcut |
| --- | --- |
| `⌘`+ `Enter` | Fullscreen |
| `⌘`+ `Left Arrow` | Previous Tab |
| `⌘`+ `Right Arrow` | Next Tab |
| `⌘` + `Number` | Go to Tab |
| `⌘` + `⌥` + `Number` | Go to Window |
| `⌘` + `⌥` + `Arrow` | Go to Split Pane by Direction |
| `⌘` + `]` or `⌘` + `[` | Go to Split Pane by Order of Use |
| `⌘` + `⇧` + `d` | Split Window Horizontally (same profile) |
| `⌘` + `d` | Split Window Vertically (same profile) |
| `⌥` + `⌘` + `⇧` + `h` | Split Window Horizontally (new profile) |
| `⌥` + `⌘` + `⇧` + `v` | Split Window Vertically (new profile) |
| `⌘` + `⇧` + `m` | Set Mark |
| `⌘` + `⇧` + `j` | Jump to Mark |

### Bonus Track

{% link https://dev.to/equiman/setup-macos-for-development-3kc2 %}

---

**That’s All Folks!**
**Happy Coding** 🖖

[![beer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mkgsx4aw6qn9i9ax6as9.png)](https://github.com/sponsors/deinsoftware)