DEV Community

Cover image for Make Windows Terminal Awesome with ZSH and Oh My ZSH!
Paul Isaris
Paul Isaris

Posted on

Make Windows Terminal Awesome with ZSH and Oh My ZSH!

TL;DR

In this guide, we'll walk you through the installation and configuration of ZSH and Oh My ZSH on Windows, so you can
enjoy the power and flexibility of these tools without leaving the comfort of your Windows environment.

Table of Contents

Introduction

Are you tired of the mundane Windows command prompt?

Do you yearn for the powerful Linux terminal, but don't
want to deal with the complexities of WSL (Windows Subsystem for Linux)?

Well, rejoice, fellow developers, for there is a solution! With the
combination of:

  1. Git Bash for Windows
  2. ZSH
  3. Oh My ZSH!

you can transform your Windows command line experience into something truly remarkable.

In this guide, we'll walk you through the installation and configuration of ZSH and Oh My ZSH on Windows, so you can
enjoy the power and flexibility of these tools without leaving the comfort of your Windows environment.

Embracing ZSH on Windows

Introducing ZSH: The Ultimate Shell Experience

ZSH

Image description: ZSH logo.

ZSH, or Z Shell, is a powerful command interpreter for UNIX-like operating systems. It offers advanced features
such as
improved tab completion, spelling correction, and extensive customization options.

Oh My ZSH!: ZSH Supercharged

Oh My ZSH!
Image description: Oh My ZSH! logo featuring a cute cartoon character with a command prompt.

But what truly takes ZSH to the next level is Oh My ZSH! This open-source framework for managing ZSH configurations
comes packed with a plethora of themes, plugins, and helpers.

Step 1: Install Git + Git Bash for Windows

If you haven't already, download and install Git for Windows from the
official website. This will give you access to Git Bash, which serves as the entry point for ZSH. You can find the
Git for Windows installer here.

Git Bash is needed so that we also have the bash shell available, which is required for ZSH to run, and also for
having the ~/.bashrc file available.
The ~/.bashrc file is installed at C:\Users\<your user name>\.bashrc.

IMPORTANT: Make sure to select the option to use Git from the Windows Command Prompt during the installation.

ALSO IMPORTANT: When opening the Windows Terminal app, make sure to select the Git Bash profile as the default
terminal profile! (Select it from the dropdown menu in the top right corner of the terminal window), and then set it as
default in the Settings.

Git Bash in Windows Terminal
Image description: Selecting Git Bash as a terminal profile

Step 2: Installation and Configuration of ZSH in Windows

Now that we understand the components, let's get down to business. Here's how you can install and configure ZSH and Oh
My ZSH! on your Windows machine without the need for WSL.

2.1: Download ZSH

Once Bash for Windows is set up, it is time to install ZSH:
Download the latest MSYS2 zsh package from the MSYS2 package repository. The file will be named
like: zsh-#.#-#-x86_64.pkg.tar.zst. You can find the latest version here.

2.2: Install ZSH

Extract the contents of the zip file (which will include etc and usr directories) into your Git
Bash

installation directory. This will be in C:\Program Files\Git. You should merge the contents of the folder when
asked (
no files should be getting overridden).

2.3: Verify the ZSH Installation

Open Git Bash and run zsh --version to ensure that ZSH is installed correctly.

2.4: Set ZSH as the Default Shell

After installation, set ZSH as your default shell by appending the following to
your C:\Users\<your user name>\.bashrc file:



   if [ -t 1 ]; then
    exec zsh
   fi


Enter fullscreen mode Exit fullscreen mode

2.5: Fix Displaying of Unexpected Characters

Fix the displaying of garbled characters on terminal by appending this line in
your C:\Users\<your user name>\.bashrc file:



   /c/Windows/System32/chcp.com 65001 > /dev/null 2>&1


Enter fullscreen mode Exit fullscreen mode

Close and reopen the terminal, to save those changes. The first time ZSH will ask for some files creation.

Step 3: Installation and Configuration of Oh My ZSH! on Windows

As we said earlier, Oh My ZSH! is the cherry on top of the ZSH cake. Let's see how you can install and configure
it on your Windows machine.

3.1: Installation of Oh My ZSH!

Install Oh My ZSH!: With ZSH in place, installing Oh My ZSH! is a breeze. Simply run:



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

Enter fullscreen mode Exit fullscreen mode




3.2: Customization of Oh My ZSH!

Fonts

Download and install manually
the Meslo Nerd Fonts to include
all glyphs and symbols that Powerlevel10k may need.

Theme

There are a lot of themes, with Powerlevel10k being the most popular and
powerful. To install it, check the instructions here.

Conclusion

Congratulations! You've now unlocked the full potential of ZSH and Oh My ZSH! on Windows. With its advanced features and
endless customization options, ZSH is sure to revolutionize your command line workflow. So why wait? Dive in today and
elevate your development experience like never before.

Top comments (6)

Collapse
 
steeve profile image
Steeve

Oh My ZSH is definitely a better prompt, compared to the default Windows terminal.
I recently moved to spaceship to create super clean prompts:

GitHub logo spaceship-prompt / spaceship-prompt

🚀⭐ Minimalistic, powerful and extremely customizable Zsh prompt

SWUbanner

spaceship →~ prompt
Spaceship Prompt 🚀⭐

Minimalistic, powerful and extremely customizable Zsh prompt

NPM Version GitHub Workflow Status Zsh Version Spaceship Twitter Chat on Discord Donate

Built with ❤︎ by Denys Dovhan and contributors

Spaceship is a minimalistic, powerful and extremely customizable Zsh prompt. Prompt is what you see when you type a command. It can show a lot of useful tips, saving your time and making the user experience smooth and pleasant. It combines everything you may need for convenient work, without unnecessary complications, like a real spaceship.

Spaceship with One Dark, zsh-autosuggestions and zsh-syntax-highlight
Visit Frequently Asked Question for similar setup and find more examples with different color schemes in Screenshots wiki-page.

✨ Features

Here are some sneak peeks of what Spaceship can show:

  • Clever hostname and username displaying
  • Repository statuses (Git and Mercurial are supported)
  • Runtime environments for various languages (Node.js, Rust, Python, Ruby, Swift, Go, PHP and many others)
  • Docker version, Kubernetes context and connected machine
  • Package version (npm, lerna, cargo…




Collapse
 
pavlosisaris profile image
Paul Isaris

Nice one, thanks! Never heard of it before. It looks a lot like one of Oh My ZSH themes, but maybe cleaner? What was your reason of choice compared to Oh My ZSH?

Collapse
 
steeve profile image
Steeve • Edited

The main reason why I migrated to Spaceship is because of the no-brain install/config and the prompt is super clean

Collapse
 
abhay_verma_4983d52bedf13 profile image
abhay verma

Great Article

Collapse
 
emanueol profile image
Emanuel Oliveira

Do we need ZSH ?
I got gitbash already installed and working in Windows Terminal, how can I have the nice git prompt without installing zsh?

Collapse
 
shaphil profile image
Shaphil • Edited

Install Oh-my-posh, ohmyposh.dev/
The default theme is nice enough.
Image description

I am using Oh-my-posh + Cmder on Windows Terminal. Here's Cmder, cmder.app/