ZSH : Oh My ZSH with Powerlevel10k

You will find in this article, the steps to install ZSH with Oh My ZSH and the theme Powerlevel10k.

More specifically, for MacOS and Windows WSL configuration.

Tools installation

For MacOS

The steps are :

  1. Installation of Xcode
  2. Installation of Homebrew (package manager)
  3. Installation of iTerm2 , ZSH, FZF, FD, Tree
  4. Installation of Oh My ZSH

The commands are :

 1# Step 1 : Xcode
 2xcode-select --install
 3
 4# Step 2 : Homebrew
 5/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
 6
 7# Step 3 : iTerm2, ZSH, FZF, FD, TREE
 8brew install iterm2 zsh fzf fd tree
 9
10# Step 4 : Oh My ZSH
11sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

For Windows WSL (and Linux)

The steps are :

  1. Installation of Windows Terminal
  2. Installation of Windows WSL Ubuntu
  3. Connect to WSL 2 with Windows Terminal and update Ubuntu
  4. Installation of ZSH, FZF, FD, Tree
  5. Installation of Oh My ZSH
 1# Step 2 : Windows WSL Ubuntu
 2
 3## Install WSL
 4wsl --install -d ubuntu
 5
 6## Check version
 7wsl -l -v
 8
 9## Set WSL2 if needed
10wsl --set-version ubuntu 2
11
12
13# Step 3 : Update Ubuntu
14sudo apt update && sudo apt upgrade
15
16
17# Step 4 : Installation of zsh fzf fd-find tree
18sudo apt install zsh fzf fd-find tree
19
20
21# Step 5 : Oh My ZSH
22sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
23# Do you want to change your default shell to zsh? [Y/n]
24Y

Tools configuration

Alias

  1. Create a config file to store all your alias ~/.alias
  2. Add the link to the alias config file ~/.alias in your ZSH config file ~/.zshrc

For MacOS & Linux :

1
2# Step 1 : Alias file creation
3touch ~/.alias
4
5# Step 2 : Add the Alias config file in ZSH config file
6echo "[[ ! -f ~/.alias ]] || source ~/.alias" >> ~/.zshrc

For Windows WSL

1
2# Step 1 : Alias file creation
3echo "alias fd=fdfind" >> ~/.alias
4
5# Step 2 : Add the Alias config file in ZSH config file
6echo "[[ ! -f ~/.alias ]] || source ~/.alias" >> ~/.zshrc

Oh My ZSH Plugins

  1. Installation of powerline fonts (you’ll find more instructions on this link)

For MacOS & Linux :

1git clone https://github.com/powerline/fonts.git
2cd fonts
3./install.sh

For Windows (with Windows Terminal) :

 1# Change the current user execution policy
 2set-executionpolicy -scope CurrentUser -executionPolicy Unrestricted
 3get-executionpolicy -list
 4
 5# Install Fonts
 6git clone https://github.com/powerline/fonts.git
 7cd fonts
 8.\install.ps1
 9
10# Change the current user execution policy
11set-executionpolicy -scope CurrentUser -executionPolicy Default
  1. Installation of the Powerlevel10k theme and the plugins (manually)
 1
 2# Install Theme 
 3git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
 4
 5
 6# Install plugins
 7git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
 8git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
 9git clone --depth 1 https://github.com/unixorn/fzf-zsh-plugin.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fzf-zsh-plugin
10git clone --depth 1 https://github.com/aubreypwd/zsh-plugin-fd ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-plugin-fd 
  1. Modification of the ZSH config file : ~/.zshrc
 1# Replace the ZSH_THEME config
 2ZSH_THEME="powerlevel10k/powerlevel10k"
 3
 4# Replace the PLUGINS config
 5plugins=(
 6    git
 7    zsh-autosuggestions
 8    zsh-syntax-highlighting
 9    fzf-zsh-plugin
10    zsh-plugin-fd 
11)

Iterm2 (for MacOS)

  1. Get the desired iTerm2 color schemes

  2. Change fonts : Navigate to iTerm2 > Preferences > Profiles > Text > Font

    1. Choose MesloLGS NF
    2. Check option : Use ligatures
  3. Import color scheme : Navigate to iTerm2 > Preferences > Profiles > Colors

    1. Click on Color Presets ... and choose Import...
    2. Click on your desired iTerm2 color scheme (from step n°1)
  4. Add Key mapping : Navigate to iTerm2 > Preferences > Profiles > Keys > Key Mappings

    1. Choose the icon +
    2. Add the following key map
ShortcutActionEsc+
⌘←Send Escape SequenceOH
⌘→Send Escape SequenceOF
⌥←Send Escape Sequenceb
⌥→Send Escape Sequencef

Windows Terminal (for Windows WSL)

  1. Get your desired color scheme from windowsterminalthemes.dev
  2. Open the Windows Terminal and navigate to Windows Terminal > Settings
    1. Go to Startup
      1. Default Profile : Ubuntu
      2. Default terminal application : Windows Terminal
    2. Go to Open your settings.json file
      1. Paste the color scheme in the schemes JSON key
    3. Go to Color Schemes
      1. choose your schemes name
    4. For each profile (Defaults, Windows PowerShell, Command Prompt, Ubuntu, Azure CLoud Shell, Git Bash, ….)
      1. Go to Appearance
        1. Color scheme : Use your color scheme
        2. Font face : MesloLGS NF

Example for the scheme modification in the JSON config file :

 1"schemes": 
 2[
 3    {...},
 4    {
 5        "background": "#1B1B1B",
 6        "black": "#1B1B1B",
 7        "blue": "#458588",
 8        "brightBlack": "#928374",
 9        "brightBlue": "#83A598",
10        "brightCyan": "#8EC07C",
11        "brightGreen": "#B8BB26",
12        "brightPurple": "#D3869B",
13        "brightRed": "#FB4934",
14        "brightWhite": "#EBDBB2",
15        "brightYellow": "#FABD2F",
16        "cursorColor": "#EBDBB2",
17        "cyan": "#689D6A",
18        "foreground": "#EBDBB2",
19        "green": "#98971A",
20        "name": "GruvboxDarkHard",
21        "purple": "#B16286",
22        "red": "#CC241D",
23        "selectionBackground": "#665C54",
24        "white": "#A89984",
25        "yellow": "#D79921"
26    },
27    {....}
28]

Powerlevel10K configuration

  1. Execute the command p10k configuration in the iterm2 or ubuntu terminal with zsh
    1. Prompt Style : Lean
    2. Character Set : Unicode
    3. Prompt Colors : 256 colors
    4. Show current time : 24-hour format
    5. Prompt Height : Two lines
    6. Prompt Connection : Disconnected
    7. Prompt Frame : Left
    8. Frame Color : Dark
    9. Prompt Spacing : Sparse
    10. Icons : Many icons
    11. Prompt Flow : Concise
    12. Enable Transient Prompt : No
    13. Instant Prompt Mode : Verbose
    14. Overwrite ~/.p10k.zsh : Yes