In this article I will tell how to make work with command prompt on Windows 10 better with Windows Subsystem for Linux
, Hyper
terminal, oh-my-zsh
framework for zsh
and zsh-syntax-highlighting
plugin.
For this article you need to have Windows 10 x64 Version 1607 Build 14393 or higher and installed Node.js.
Install Windows Subsystem for Linux
If you have installed Windows 10 Build Less Than 16215:
First, you need to install Windows Subsystem for Linux. Go to Settings -> Update and Security -> For developers
and change Sideload apps
setting to Developer mode
Next open command prompt and go to OptionalFeatures.exe
and enable Windows Subsystem for Linux (Beta)
then reboot your PC. After rebooting you need to open command prompt and use bash
command. Then begin automatic downloading and installation of Linux Subsystem.
In the next time when you need to use bash shell open command prompt and use bash
command.
If you have installed Windows 10 Version 1709 (Fall Creators Update) Build 16215 or Higher:
Go to Settings -> Update and Security -> For developers
and change Sideload apps
setting to Developer mode
.
Open command prompt and go to OptionalFeatures.exe
and enable Windows Subsystem for Linux
then reboot your PC.
Since Fall Creators Update
we need to install Windows Subsystem for Linux from Windows Store.
For now (21 October 2017) we have three Linux distributions in Windows Store to choose from:
I recommend to install Ubuntu to this article.
Then after installing Ubuntu and rebooting PC you can run it with bash
or ubuntu
commands in command prompt.
In more detail, this parts is described in Installation Guide on the Microsoft Official Website.
Install Hyper Terminal
Go to official hyper terminal website and download latest version of terminal for Windows.
Install cURL and Git
Go to bash terminal installed above and use following commands:
- Install cURL:
- Install Git:
Install Zsh
To install Zsh use following command:
Install Oh My Zsh
Official GitHub repository of oh-my-zsh project https://github.com/robbyrussell/oh-my-zsh
To install oh-my-zsh go to bash terminal and use following command:
and wait until the installation is completed.
Configure and Run Oh My Zsh
Now each time when you need to use bash shell and zsh you need go to command prompt, use bash
(or ubuntu
) command and then use zsh
command.
Let’s simplify it.
If you have installed Windows 10 Build Less Than 16215:
Open bash terminal using bash
command and use nano ~/.bashrc
to open .bashrc
config file.
Warning: Do not change Linux files using Windows apps and tools
In start of that file add following command:
Example: .bashrc
file on gist
Note that in this time if you will try to use “default” command chsh -s /bin/zsh
in bash shell terminal it will not run zsh as default bash shell environment.
Look at this comment of Ben Hillis @benhillis - https://github.com/Microsoft/BashOnWindows/issues/1724#issuecomment-282420193
Now each time when you will use bash
in command prompt then zsh
will start automatically instead of bash shell.
If you have installed Windows 10 Version 1709 (Fall Creators Update) Build 16215 or Higher:
Since Windows 10 Fall Creators Update you can run WSL with ubuntu
command and chsh
command will works.
https://github.com/Microsoft/BashOnWindows/issues/2199#issuecomment-334453644
So open ubuntu
command in command prompt and use following command:
Each time when you will run ubuntu
command then zsh
will runs automatically as the default shell environment.
Note that this still will not work if you will run the bash
command.
Configure and Run Hyper Terminal
If you have installed Windows 10 Build Less Than 16215:
After you installed Hyper Terminal open %USERPROFILE%/.hyper.js
config file and replace line:
with
Now each time when you will open hyper terminal it’s will be use zsh
as default shell environment.
If you have installed Windows 10 Version 1709 (Fall Creators Update) Build 16215 or Higher:
After you installed Hyper Terminal open %USERPROFILE%/.hyper.js
config file and replace lines:
and:
with:
and:
respectively.
Short Q&A:
- Question:
Why not just use path to ubuntu.exe
file in hyper.is config?
- Answer:
You can just use ubuntu.exe
or full path to ubuntu.exe
without any shell arguments:
or
but in this case your hyper terminal will opens only in Ubuntu home directory.
Links to related issues about this:
Solution: we can use cmd.exe
in config and just run wsl
as a command line argument. That’s works.
Also, note that in this case we are running wsl.exe
not ubuntu.exe
and this running Ubuntu because Ubuntu is current default “WSL OS”. For example if you will install openSUSE
from Windows Store and set as default then wsl.exe
will run openSUSE
.
To understand what I mean, I recommend to reading article: Manage multiple Linux Distributions in WSL.
- There is a second way to solve:
Also you can just use wsl.exe
without any shell arguments:
And that’s works too.
Without installed themes for hyper this will looks like this:
Themes and other plugins for Hyper Terminal you can find here https://github.com/bnb/awesome-hyper.
I use hyper-material-theme theme by Mattia Astorino @equinusocio.
Change Oh My Zsh Theme
List of Oh My Zsh themes you can find here https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
By default oh-my-zsh use robbyrussell
(like on screen above). If you want to change theme open ~/.zshrc
config file by use following command in terminal:
and change default “robbyrussell” value of ZSH_THEME
variable to another theme name that you need to enable.
Known Issue: Hot key
Ctrl + X
in Hyper Terminal Does not Work. Instead of this useShift + Ctrl + X
. Link to Related GitHub Issue https://github.com/zeit/hyper/issues/1069
Known Issues for Windows Subsystem for Linux here https://github.com/Microsoft/BashOnWindows
Install zsh-syntax-highlighting plugin
Official GitHub repository of project https://github.com/zsh-users/zsh-syntax-highlighting
This plugin provides syntax highlighting in terminal like in Fish
shell.
Open terminal and download zsh-syntax-highlighting
plugin to .oh-my-zsh
plugins directory using git:
If $ZSH_CUSTOM
variable exist and contains value (full path to /.oh-my-zsh/custom
in this case) use its value, otherwise use ~/.oh-my-zsh/custom
.
About :-
(colon dash) you can read in this topic on stackoverflow: Usage of :- (colon dash) in bash.
Next to activate this plugin open ~/.zshrc
config file using nano ~/.zshrc
and find the following text:
Here you need to add zsh-syntax-highlighting
to plugins
list. For that just replace
with
and save changes.
Finally you need to take changes into account. For that use follow command:
And now after restart hyper terminal you can see result. Screen:
- windows (1) ,
- zsh (1) ,
- shell (1) ,
- syntax (1) ,
- highlighting (1) ,
- ohmyzsh (1) ,
- hyper (1) ,
- terminal (1)
- windows (1) ,
- zsh (1) ,
- shell (1) ,
- syntax (1) ,
- highlighting (1) ,
- ohmyzsh (1) ,
- hyper (1) ,
- terminal (1)