ZSH : Oh My ZSH with Powerlevel10k
Last update : 1 May 2023
Reading time : 5 minute(s) - 854 words
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 :
- Installation of Xcode
- Installation of Homebrew (package manager)
- Installation of iTerm2 , ZSH, FZF, FD, Tree
- 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 :
- Installation of Windows Terminal
- Installation of Windows WSL Ubuntu
- Connect to WSL 2 with
Windows Terminal
and updateUbuntu
- Installation of ZSH, FZF, FD, Tree
- 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
- Create a config file to store all your alias
~/.alias
- 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
- 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
- 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
- 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)
Get the desired iTerm2 color schemes
Change fonts : Navigate to
iTerm2 > Preferences > Profiles > Text > Font
- Choose
MesloLGS NF
- Check option :
Use ligatures
- Choose
Import color scheme : Navigate to
iTerm2 > Preferences > Profiles > Colors
- Click on
Color Presets ...
and chooseImport...
- Click on your desired iTerm2 color scheme (from step n°1)
- Click on
Add Key mapping : Navigate to
iTerm2 > Preferences > Profiles > Keys > Key Mappings
- Choose the icon
+
- Add the following key map
- Choose the icon
Shortcut | Action | Esc+ |
---|---|---|
⌘← | Send Escape Sequence | OH |
⌘→ | Send Escape Sequence | OF |
⌥← | Send Escape Sequence | b |
⌥→ | Send Escape Sequence | f |
Windows Terminal (for Windows WSL)
- Get your desired color scheme from windowsterminalthemes.dev
- Open the Windows Terminal and navigate to
Windows Terminal > Settings
- Go to
Startup
- Default Profile :
Ubuntu
- Default terminal application :
Windows Terminal
- Default Profile :
- Go to
Open your settings.json file
- Paste the color scheme in the
schemes
JSON key
- Paste the color scheme in the
- Go to
Color Schemes
- choose your schemes name
- For each profile (Defaults, Windows PowerShell, Command Prompt, Ubuntu, Azure CLoud Shell, Git Bash, ….)
- Go to
Appearance
- Color scheme : Use your color scheme
- Font face :
MesloLGS NF
- Go to
- Go to
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
- Execute the command
p10k configuration
in theiterm2
orubuntu
terminal withzsh
- Prompt Style :
Lean
- Character Set :
Unicode
- Prompt Colors :
256 colors
- Show current time :
24-hour format
- Prompt Height :
Two lines
- Prompt Connection :
Disconnected
- Prompt Frame :
Left
- Frame Color :
Dark
- Prompt Spacing :
Sparse
- Icons :
Many icons
- Prompt Flow :
Concise
- Enable Transient Prompt :
No
- Instant Prompt Mode :
Verbose
- Overwrite
~/.p10k.zsh
:Yes
- Prompt Style :