Beautify your Linux Terminal: Ohmyzsh+wsl+Hyper.js!

Devanshu Tiwari
4 min readJan 17, 2021
Spaceship theme on Hyper.js on Windows using Ohmyzsh!

Do you like the comfort of Windows, but also want to use a cool Linux terminal ๐Ÿ’ป ? In this article, we will explore the steps to configure Hyper.js to use Ohmyzsh! with Spaceship theme using wsl on Windows. ๐Ÿ˜‰

The popularity of Linux among developers, and the fact, that majority of servers on internet use some version of Linux, pushed Microsoft to come up with โ€œwsl- Windows Subsystem for Linuxโ€. With WSL, you can have a minimal version of Linux kernel on your windows OS, even without installing any virtual machine or a dual-boot system.

Our goal: A ๐Ÿ†’ Linux Terminal shell with auto-completion and auto-suggestion features along with all the awesomeness Linux has to offer.

Requirements: Windows Operating System with VSCode Editor installed.

Letโ€™s get started ! (PLease keep patience, when some libraries take time to install ๐Ÿ˜›)
Note: Everything between ๐Ÿƒxyz123๐Ÿƒ is the code that has to be copied and run on your terminal.
& Everything that is between ๐Ÿ“‹
xyz123๐Ÿ“‹ has to be copied and then added/replaced as mentioned in the respective step.

Step 1: Enable wsl on Windows : Use WindowsKey+ X to run Powershell in elevated mode and paste the following command:

๐Ÿƒ dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart ๐Ÿƒ

Step 2: Restart Your Machine.

Step 3: Install a linux distribution form Microsoft App Store : I prefer Ubuntu (my version is 20.04) and then Launch it.
Create a username and password for this OS.

Step 4: Update package manager and libraries:
๐Ÿƒ sudo apt-get update ๐Ÿƒ
๐Ÿƒ sudo apt-get upgrade ๐Ÿƒ

Step 5: Now install zsh
๐Ÿƒ sudo apt-get install zsh ๐Ÿƒ
๐Ÿƒ zsh ๐Ÿƒ
Select the option to create an empty .zshrc file by pressing 0 and hitting Enter.

Step 6: Install Oh My Zsh: we will use curl to install it. So, make sure curl is installed first. Most probably curl and Git got already installed as we upgraded our libraries .
๐Ÿƒ sudo apt-get install curl ๐Ÿƒ
๐Ÿƒ sh -c โ€œ$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" ๐Ÿƒ

When prompted select y to set zsh as your default shell and click Enter.

Step 7: Install spaceship theme for prompt
๐Ÿƒgit clone https://github.com/denysdovhan/spaceship-prompt.git โ€œ$ZSH_CUSTOM/themes/spaceship-promptโ€ ๐Ÿƒ
Then, 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โ€ ๐Ÿƒ

Step 8: Edit configuration file for zsh
๐Ÿƒ code ~/.zshrc๐Ÿƒ
Add the below code at the end of the 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=โ€ โ€œ ๐Ÿ“‹

Step 9: Install Fira Code Font on your system.
https://github.com/tonsky/FiraCode. Download the zip file and extract it. Open the tty folder and click on each font file and click install. Select all the fonts on the folder one by one without missing any file.
Restart the shell.

Step 10: Now install Hyper terminal and configure it :https://hyper.is/. Press ctrl + ,
This will open hyper.js configuration file. Replace the following code if it exists or create it: Do not forget to replace the username in shell path with your username, your shell path will be different than mine, do change it!

๐Ÿ“‹ fontFamily: โ€˜โ€œFira Codeโ€, Menlo, โ€œDejaVu Sans Monoโ€, โ€œLucida Consoleโ€, monospaceโ€™,

shell: โ€˜C:\\Users\\devqu\\AppData\\Local\\Microsoft\\WindowsApps\\ubuntu2004.exeโ€™,

shellArgs: [],

plugins: [โ€˜hyper-draculaโ€™], ๐Ÿ“‹

Restart the hyper terminal.

Step 11: Install Plugins: zsh-completions, zsh-autosuggestions and fast-syntax-highlighting:

๐Ÿƒ sh -c โ€œ$(curl -fsSL https://raw.githubusercontent.com/zdharma/zinit/master/doc/install.sh)"๐Ÿƒ

Step 12: Configure the zshrc file
๐Ÿƒ code ~/.zshrc๐Ÿƒ
Add the following lines at the end of it:
๐Ÿ“‹zinit light zdharma/fast-syntax-highlighting
zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-completions๐Ÿ“‹

Step 13: Install wsl remote extension for vscode, it will update the terminal for VS Code automatically!๐Ÿ˜ƒ
Optionally, you can change the default terminal for local window file system as well :
Open vscode config: ctrl + shift +p and add this line to JSON settings file for user

๐Ÿ“‹โ€œterminal.integrated.shell.windowsโ€: โ€œC:\\Users\\devqu\\AppData\\Local\\Microsoft\\WindowsApps\\ubuntu2004.exeโ€,๐Ÿ“‹

Step 14: Installing node on our new ubuntu container, as it canโ€™t access the node installed on windows.
First install basic build tools for node-gyp that complies native add-on tools for node:
๐Ÿƒ sudo apt-get install build-essential๐Ÿƒ
Then , install node version manager (nvm):
๐Ÿƒ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash ๐Ÿƒ

Step 15: Configure the zshrc file
๐Ÿƒ code ~/.zshrc๐Ÿƒ
Add the followings line at the end of the file and save it.

๐Ÿ“‹export NVM_DIR=โ€$HOME/.nvmโ€
[ -s โ€œ$NVM_DIR/nvm.shโ€ ] && \. โ€œ$NVM_DIR/nvm.shโ€๐Ÿ“‹

Step 16: Install node:
๐Ÿƒ source ~/.zshrc๐Ÿƒ
๐Ÿƒ nvm install โ€” lts๐Ÿƒ
๐Ÿƒ nvm use โ€” lts๐Ÿƒ
Check the version of node installed by running the command:
๐Ÿƒ node โ€” version๐Ÿƒ

Congratulations ๐Ÿท for configuring your terminal successfully!
Optionally, you may also want to remove your username from prompt. To do that edit the zshrc config file :
๐Ÿƒ code ~/.zshrc๐Ÿƒ
And comment out the user from spaceship prompt order.

--

--

Devanshu Tiwari

If you canโ€™t explain it simply, you donโ€™t understand it well enough