DEV Community

Joel Lau
Joel Lau

Posted on • Updated on

zsh on windows

End Goal

To build a terminal environment with:

  • MSYS2
  • Windows Terminal
  • Winget
  • Zsh
  • Oh My Zsh
  • Zsh Theme Of Choice: PowerLevel10k

Instructions

Install Windows Terminal and MSYS2 using CMD or PowerShell:



winget install Microsoft.WindowsTerminal ;
winget install MSYS2.MSYS2 ;


Enter fullscreen mode Exit fullscreen mode

Open MSYS2 from windows search bar and start installing from there:

Image description



# Install git and ZSH
pacman -S git zsh ;

# Install Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" ;

# Generate ~/.zshrc
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc ;


Enter fullscreen mode Exit fullscreen mode

Create MSYS2 Profile for Windows Terminal (use zsh):

  1. Open the Windows Terminal App
  2. Open the Settings Pane (CTRL + .)
  3. Click on Open JSON
  4. Add this item to profiles.list and change profiles.default to the same guid ({71160544-14d8-4194-af25-d05feeac7233})


{
  "commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -msys -use-full-path -shell zsh",
  "elevate": true,
  "guid": "{71160544-14d8-4194-af25-d05feeac7233}",
  "icon": "C:/msys64/msys2.ico",
  "name": "MSYS / MSYS2",
  "startingDirectory": "C:/msys64/home/%USERNAME%"
}


Enter fullscreen mode Exit fullscreen mode

Restart Windows Terminal and you should be able to see Zsh running.

Install ZSH Plugins



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

# Syntax Highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# Autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions


Enter fullscreen mode Exit fullscreen mode

In your ~/.zshrc, look for a line that says ZSH_THEME and change it to



ZSH_THEME="powerlevel10k/powerlevel10k"


Enter fullscreen mode Exit fullscreen mode

In the same file, also modify the list of plugins: (ignore ssh-agent and gpg-agent if you haven't set up git)



plugins=( 
    git
    ssh-agent
    gpg-agent
    zsh-syntax-highlighting
    zsh-autosuggestions
)


Enter fullscreen mode Exit fullscreen mode

Restart Windows Terminal for the final time and you should be brought to a powerlevel10k's wizard :)

References

EDIT: added suggestions from James 'Dante' Midzi's comments

Top comments (2)

Collapse
 
psypher1 profile image
James 'Dante' Midzi

It would be cool if you mentioned where the first installation needs to be (command prompt, poweshell etx) and what administrator rights are required

Collapse
 
joellau profile image
Joel Lau

thanks for the feedback!