DEV Community

Cover image for How to Install Oh My Zsh! on Windows 10 Home Edition
Vinícius Albuquerque
Vinícius Albuquerque

Posted on

How to Install Oh My Zsh! on Windows 10 Home Edition

As a developer, some tools may be a game changer for your productivity, but sometimes we just need to work in an environment that makes things easier for us.

If you're constantly making typos on commands, or everything being on the same color makes it difficult to see mistakes, it will not be a big deal when you analyze those mistakes alone. But in reality, those things pile up until you find it weird that you are so tired at the end of the day. And this happens because you are using a lot of your focus just to make sure everything is alright while you're working.

I this tutorial, I'll show you how to set up a terminal that makes things easier while working, so that you can focus on what is really important and stop wasting your energy on small things.

This is the result you should have at the end:

terminal pic

Warning: This tutorial is for people who are using Windows 10 Home Edition. It doesn't have Hyper-V, so the only way of having bash is via WSL1. If you have Hyper-V on your version, try installing WSL2. The rest of steps of the tutorial may be the same, though.

At the end, you will have:

  • An Oh My Zsh! terminal instance, with all the benefits it brings out of the box.
  • Spaceship Prompt theme applied, so that you have cool highlighting and signs that show the current state of the git repository you're in (if there are things changed that were not staged, staged but not committed, etc.).
  • Hyper as an alternative to open Oh My Zsh! with font ligature's feature.
  • Visual Studio Code shell integration, so that you can use it inside the IDE.
  • NVM and Node working on your terminal.

The Benefits

  • Automatic cd: Just type the name of the directory
  • Recursive path expansion: For example “/u/lo/b” expands to “/usr/local/bin”
  • Spelling correction and approximate completion: If you make a minor mistake typing a directory name, ZSH will fix it for you
  • Plugin and theme support: ZSH includes many different plugin frameworks

1. Activate "Windows for Linux Subsystem" Feature

  • Run this script on PowerShell:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
  • Restart your machine.

2. Install a Linux Distribution

You shouldn't have problems in this step. Just open Microsoft Store App and search for a distro. In my case, I installed Debian.

3. Install Zsh

Open Debian from Start Menu. It will open a command prompt with the same features as Debian's terminal.

If you try to run sudo apt-get install zsh first, you may receive an error (Unable to locate package zsh). So, first you should run these two commands:

$ sudo apt-get update
$ sudo apt-get upgrade

Now you will be able to install Zsh properly, running:

$ sudo apt-get install zsh

When the installation is done, run this:

$ zsh

This will walk you through some basic configuration for zsh.

4. Install Oh My Zsh!

Install curl:

$ sudo apt-get install curl

Install Oh My Zsh!:

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

While installing, it will ask if you want to set zsh as standard. Answer the prompt as you wish.

5. Set the theme Spaceship Prompt as default for Oh My Zsh!

Install Git:

sudo apt-get install git

Clone the theme's repository:

git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"

Symlink spaceship.zsh-theme to your oh-my-zsh custom themes directory:

ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"

Now you must edit Zsh configuration file so that Oh My Zsh! uses this theme. If you already have Visual Studio Code installed, you can open the file using the code bellow:

code ~/.zshrc

Add this line at the end of your .zshrc file:

Set ZSH_THEME="spaceship"

SPACESHIP_PROMPT_ORDER=(
  user          # Username section
  dir           # Current directory section
  host          # Hostname section
  git           # Git section (git_branch + git_status)
  hg            # Mercurial section (hg_branch  + hg_status)
  exec_time     # Execution time
  line_sep      # Line break
  vi_mode       # Vi-mode indicator
  jobs          # Background jobs indicator
  exit_code     # Exit code section
  char          # Prompt character
)
SPACESHIP_USER_SHOW=always
SPACESHIP_PROMPT_ADD_NEWLINE=false
SPACESHIP_CHAR_SYMBOL="❯"
SPACESHIP_CHAR_SUFFIX=" "

Before going ahead, you need to install Fira Code font. Follow the instructions here.

6. Install Hyper Terminal

You must have noticed the terminal is kinda buggy right now. It seems the fonts do not load properly. So, we will install Hyper to solve that problem. It will give you a pleasant experience, supporting all Spaceship Theme's features.

Just go to https://hyper.is and click the big download button, at the right on your screen. Then open it and follow the instructions.

After that, open Hyper and its "Preferences" file (Ctrl + ,).

{
  ...
  // add Fira Code as first font in font family with optional fallbacks
  fontFamily: '"Fira Code", Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
  ...
  shell: 'C:\\Users\\<your-user-name>\\AppData\\Local\\Microsoft\\WindowsApps\\debian.exe',
  shellArgs: [],
  ...
}

Important: Change <your-user-name> to your username on Windows. If you have installed other Linux distribution, change shell path accordingly. I believe all distributions installed via Microsoft Store will be at the same place, but I don't know for sure.

Another important thing: Your shellArgs attribute must be an empty array, otherwise it will not work.

I like the theme Dracula for Hyper. If you wish that too, add this on the config file too:

plugins: [
  'hyper-dracula'
]

7. Add plugins to your terminal

Now we're going to add some cool features:

  • fast-syntax-highlighting: It adds syntax highlighting to your terminal, showing what typos you made;
  • zsh-autosuggestions: It suggests commands as you type based on history (commands you've used before) and completions;
  • zsh-completions: It adds thousands of completions for usual tools like Yarn, NVM, Node, etc, so that you need only to press TAB to complete the command.

Fetch and run zinit script:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/zdharma/zinit/master/doc/install.sh)"

Open zsh configuration file again:

code ~/.zshrc

Add this line at the end of your .zshrc file:

zinit light zdharma/fast-syntax-highlighting
zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-completions

8. Set up Visual Studio Code shell integration

  • Open Visual Studio Code
  • Ctrl + Shift + p
  • Open settings JSON
  • Add this line (or change it, if it already exists):
"terminal.integrated.shell.windows": "C:\\Users\\<your-user-name>\\AppData\\Local\\Microsoft\\WindowsApps\\debian.exe",

Important: Remember to change <your-user-name> to your actual Windows user name.

9. Don't Forget to set up Node

Some things you have installed on Windows will work already, but you'll have to install node specifically on your distro. We will use NVM (Node Version Manager) to have more freedom, if sometime we need to downgrade the version used keeping the other ones.

First, we need to install the basic build tools for node-gyp.

To do that, run this on your terminal:

$ sudo apt-get install build-essential

Then you'll have to download and run the script for installing NVM:

Important: Before running this, check if it has the last version on the website (0.35.3).

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

After that, close the terminal and open it again.

Now, you'll add again some more settings to .zshrc file.

code ~/.zshrc

Paste this code at the end of the file:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

To load the changes you've just made, run

source ~/.zshrc

Now, finally, we're ready to install node's lastest LTS version:

$ nvm install --lts

Set this version as the version nvm should use as standard:

nvm use --lts

Conclusion

Phew!!! If you endured until the end, congratulations. It was surely a long ride for me.

I just want to highlight something before ending this article: The path structure for navigating folders is a little different.

If you want to go to C:\Users\MyUserName\Documents\awesome-repo, for example, you will use cd /mnt/c/Users/MyUserName/Documents/awesome-repo.

This means your drives are at /mnt/. From there, the path structure is pretty much the same.

I hope this was helpful to someone.

If something didn't work for you, or even if you have found a workaround for some specific problem, please leave a comment and I'll update this article as soon as possible. I'm sure it will help someone who passes by in the future.

Top comments (59)

Collapse
 
sahansj34 profile image
sahansj34

Hi there thanks so much for the tutorial.

However im stuck at trying to installing nvm. after the source ~/.zshrc execution i get a

/home/sj/.zshrc:101: command not found: Set

I seem to have followed the earlier steps properly and I do not know why.

Please help...

Collapse
 
borsemayur2 profile image
Mayur Borse

I removed the Set part of the command. It worked for me.

Collapse
 
randlelanre profile image
Randle Kehinde Olanrewaju

I am also getting the same error as you, can someone please shed light on this

Collapse
 
pandahutmiku profile image
Miku

The set command is case-sensitive. Just change "Set" to "set"

Thread Thread
 
omarkhangithub profile image
Omar Khan

This works!! Thanks @pandahutmiku
I just changed
Set ZSH_THEME="spaceship" (in .zshrc) TO
set ZSH_THEME="spaceship"

WORKING PERFECTLY!

Collapse
 
cleancodestudio profile image
Clean Code Studio

AMAZING article sir, huge thank you to the immense amount of detail and effort put into setting up an amazing terminal workflow within windows.

I've been on mac/linux for the past few years and recently had to switch back to windows for a new gig. This terminal set up will help the workflow tremendously, thank you!

This article just made life and my personal workflow MUCH more enjoyable. Thank you!

Collapse
 
vsalbuq profile image
Vinícius Albuquerque

I'm really happy to read that, Zak! Thank you very much for sharing it!

Collapse
 
cleancodestudio profile image
Clean Code Studio

Absolutely it deserves to be shared. I owe you a huge thank you, even just a week after reading this article I've taken a descent deep dive into electron as a whole. I've always known it's out there, but justified not deep diving into a rabbit whole.

I was shared this article on my youtube channel and at work. Then, perfectly timed, I actually ran into some problems with a small app I'm building that electron solved perfectly and quickly.

After working with in a minor way on an application, I was fanboying over electron to the lead software developer at my company. Two days later we were talking about it again and I was showing him my personal electron project.

Now, as I did a week earlier, he's coming to understand the incredible power behind Electron as well and we've been full geek out on the possibilities it has for our company. Nothing is for sure as of yet, but out of the blue he said "I can't wait to have you start building out our internal electron project to see what you can do with it."

It's an amazing company and they focus a ton on high quality talent, hiring less than 3% of applicants.

This week is only my third week, and although not a forsure thing, this article may have lead to an incredible opportunity early on a place stacked plum to the brim with talent and other needs.

Thank you for this share, I'll be checking in to see any new posts you create :)

Thread Thread
 
vsalbuq profile image
Vinícius Albuquerque

Wow, Zak... That is amazing! Very happy to help!

Collapse
 
nivnahmias profile image
Niv Nahmias • Edited

Thanks for the great guide.

I'm having some issues setting the default shell for hyper to ubuntu.
My ubuntu shell is located at:
C:\Users\Niv\AppData\Local\Microsoft\WindowsApps\ubuntu2004.exe

I can verify this path is correct by running it.
I also tried setting the shell property to 'C:\Windows\System32\wsl.exe' as suggested in many other places.
However, setting it as the shell configuration in hyper does nothing. still opens with cmd. (i've made sure to keep shellArgs empty).

Do you have any idea how to fix this?

Collapse
 
vsalbuq profile image
Vinícius Albuquerque

That's weird... What path appears if you run the script bellow?

where ubuntu2004.exe
Enter fullscreen mode Exit fullscreen mode

If this returns a path different from the one you're using, try to use that path instead of the one you're trying to use and let me know if it's working.

Also, your shellArgs array on Hyper's settings must be empty. Have you checked that too?

Collapse
 
nivnahmias profile image
Niv Nahmias

it's the same path as the one i used.
yes, shellArgs are empty.

are you able to set up this guide using this version of ubuntu?

Thread Thread
 
vsalbuq profile image
Vinícius Albuquerque

I'm very busy these past months (couldn't even keep posting here). Sorry...

I hope you find a way to work around the issues you've found. And if you do, please comment the solution here... Maybe someone else will need that answer too.

Collapse
 
pbxed profile image
Jordan Shenolikar

In my case it was a missing comma after copy-pasting from the instructions that was causing hyper to not be able to process the config file. Everything worked on ubuntu2004.exe after spotting this for me.

plugins: [
'hyper-dracula'
], <-----

Collapse
 
nivnahmias profile image
Niv Nahmias

this was exactly my issue, thank you so much.
too bad hyper doesn't output an error when trying to parse this config json

Collapse
 
mauryarohit profile image
mauryarohit

Thanks for the article. Appreciate it so much.
However, if you follow the above mentioned Step 8 your terminal will not open with current workspace folder, to solve this follow these steps instead:

  1. Click Ctrl + Shift + P, search "Terminal: Select Default Profile" and select your Linux distro. Hope this helps too!!
Collapse
 
affanthebest profile image
Siddiqui Affan • Edited

It's still not not opening with current workspace folder

Collapse
 
unlockdep profile image
Dawood Sulaiman Syed

I've encountered an issue. When I run

nvm install --lts

I get an error saying that I don't have it installed even tho I just did the commands all right without errors and I regularly have node installed as I am a we developer.

Collapse
 
vsalbuq profile image
Vinícius Albuquerque

It's kind of difficult to find it out only with the information you gave me...

Have you forgotten the step for adding the path variable to .zshrc, maybe?

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Enter fullscreen mode Exit fullscreen mode

It may be also that you .zshrc wasn't saved before you tried to run nvm.

Also, if you changed the file structure to remove the mnt/, it may cause some issues.

I hope this helps, but I'm really in the dark here, 😅

Collapse
 
joffreydrummond profile image
Joffrey Drummond

I was having the same issue. If you read the prompt after installing nvm from the repo it says you need to close the terminal or run the below script.

I closed and reopened and nvm installed successfully

I hope this helps!

Collapse
 
aldorr profile image
Allan Dorr

Thanks Vinícius, this was very helpful.
One thing I would like to add, is making an alias in ~/.zshrc for VSCodium or VSCode, so you can open files from the command line.
For this I added:

alias code="/mnt/c/Program\ Files/VSCodium/VSCodium.exe"
Enter fullscreen mode Exit fullscreen mode

or you use your path to VS Code, wherever that is. I.e.:

alias code="/mnt/c/Users/{Username}/AppData/Local/Programs/Microsoft\ VS\ Code"
Enter fullscreen mode Exit fullscreen mode

This makes jumping back and forth a little easier.

Collapse
 
rubengmurray profile image
Reece Daniels • Edited

A couple of things I found whilst walking through:

  • Step 1: Needed to run Powershell as Administrator (even though my windows account is an admin)

  • Step 4: Needed git installed before I could run sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

  • Step 7: Re-opening Hyper, I see /home/user/.zshrc:103: command not found: Set at the top of my terminal

  • Step 7: sh -c "$(curl -fsSL https://raw.githubusercontent.com/zdharma/zinit/master/doc/install.sh)" returns a 404

  • Step 8: Adding the "terminal.integrated.shell.windows": "C:\\Users\\<your-user-name>\\AppData\\Local\\Microsoft\\WindowsApps\\debian.exe", into VS code returns the following error (seems to still work though)

This is deprecated, the new recommended way to configure your default shell is by creating a terminal profile in `#terminal.integrated.profiles.windows#` and setting its profile name as the default in `#terminal.integrated.defaultProfile.windows#`. This will currently take priority over the new profiles settings but that will change in the future.(2)
Enter fullscreen mode Exit fullscreen mode

Step 9: Appreciate the note on version of nvm - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash worked

Step 9: The following was already in my .zshrc after nvm install

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Enter fullscreen mode Exit fullscreen mode
Collapse
 
sim1029 profile image
Simon Schueller

For step 7 You should use this command instead

sh -c "$(curl -fsSL https://git.io/zinit-install)"

Collapse
 
joffreydrummond profile image
Joffrey Drummond

I actually used Terminal, then followed the same steps to add and use Debian in Terminal.
OMG my Terminal is so gorgeous now. I am going to make branches on personal projects just to see the colors lol

One thing that didn't work was nvm install though. I am not sure why and am down a rabbit hole of the internet to figure it out

Thanks for this guide I have been nerding out and telling devs who do not care this morning haha

Collapse
 
reverseroach profile image
Ant

I ended up running "git clone github.com/creationix/nvm.git .nvm" instead, and then "source ~/.nvm/nvm.sh" before "source ~/.zshrc" and it worked for me

Collapse
 
rajdeepmondal1 profile image
Rajdeep Mondal

Hey,
Thanks for your advice, I used github.com/nvm-sh/nvm.git and installed node-v15.14.0 and it worked.

Collapse
 
raman2106 profile image
raman2106

VS code is displaying the following message for step 8:

This is deprecated, the new recommended way to configure your default shell is by creating a terminal profile in Terminal › Integrated › Profiles: Windows and setting its profile name as the default in Terminal › Integrated › Default Profile: Windows. This will currently take priority over the new profiles settings but that will change in the future.

Help!!

Collapse
 
mauryarohit profile image
mauryarohit

Follow this for Step 8 instead:
Click Ctrl + Shift + P, search "Terminal: Select Default Profile" and select your Linux distro.

Collapse
 
irfan87 profile image
Ahmad Irfan Mohammad Shukri

I am facing this problem. Hope you can help me. I have attached the image to you so I hope you can view it. The problem is in the Hyper, when I list all the directories with ls, all the main folders' background become green. And I would like to fix but I don't have any idea where to fix. I have fixed at the ZSH and Hyper but no positive result.

Collapse
 
vsalbuq profile image
Vinícius Albuquerque

Sorry, I can't see your image and didn't understand what you said. Would you send it again?

Collapse
 
irfan87 profile image
Ahmad Irfan Mohammad Shukri

hahha.. that's okay. I've already fixed it. =)

Thread Thread
 
imtejasvi profile image
im-tejasvi

how did u fix it?

Collapse
 
noahack88 profile image
noahack88

My yarn commands are only working inside the default ~ directory. As soon as I cd out into where my other react apps are I can use the yarn command but it does not work. Also I am a bit confused where the files are on the computer at the beginning of the file path. Help would be appreciated, and I can be more clear if my explanation was not good.

Collapse
 
kyokatarz profile image
Giang Tran • Edited

Hey thanks for instructive guide. I really like it. One thing I wanna ask tho, when I run zsh in VSC (it works), its default path is set to /home/. Adding cwd in VSC config crashes the terminal immediately.

Do you know how to set the zsh default path to project's path on terminal launch?

Collapse
 
outcastdreamer profile image
Saket Savarn • Edited

Hey, thanks for such an amazing article!! This is how my Hyper terminal looks like (dev-to-uploads.s3.amazonaws.com/up...). Different themes but the same tutorial. I am trying to figure out how to add a custom background image with opacity in my terminal. I tried the 'hyper-wallpaper' plugin & this link stackoverflow.com/questions/387953... but don't aren't working for some reason. Can you show me a working example if possible?

Collapse
 
chrislfieldsii profile image
Christopher Fields

This article was a lifesaver for me being able to work on my gaming PC sometimes too. Before this, I just refused to develop on my windows machine unless absolutely necessary but now it is a bit more bearable

Collapse
 
borsemayur2 profile image
Mayur Borse

OMG. I never thought running linux commands (specillay oh-my-zsh) on windows. Thanks for the amazing article. I have followed each step and now ready to ride the linux wave on windows shore. Thanks to you.