Documents the steps necessary to install a good terminal in Windows using the Windows Subsystem for Linux (WSL). At the end, it should look like:
Install the Windows Subsystem for Linux and the Linux distribution of choice. In our case, we'll use Ubuntu provided by the Windows Store.
- Enable the "Windows Subsystem for Linux" feature:
- Press the Windows key (
WIN
) and type "Turn Windows features on or off" - Find and enable "Windows Subsystem for Linux".
- Restart your computer if prompted.
- Press the Windows key (
- Install Ubuntu
- Press
WIN
and type "Ubuntu" (or go here) and select the Windows Store option. - Provide a UNIX username (
'amsmith'
) and password during the installation steps. - Install the latest version(s) of the distro and of all dependencies:
$ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get dist-upgrade $ sudo apt-get autoremove
- Press
If you run ls -a
, you should see .bash_logout
, .bashrc
, and .profile
.
If you wish to access this root path (~
) in Windows, navigate to:
C:\Users\$WINDOWS_USER\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\$UBUNTU_USER
Install Zsh, a feature-rich shell with lots of features above and beyond the default shell.
- Install Zsh:
$ sudo apt-get install zsh
- Step through first-time configuration and select the option which creates a blank
.zshrc
file:$ zsh
...
(0) Exit, creating the file ~/.zshrc containing just a comment. That will prevent this function being run again.
... - Set
zsh
to be your preferred login shell:$ chsh -s $(which zsh)
If you exit and reload your terminal, it should load into Zsh.
Install Prezto, a configuration framework for Zsh that enriches the command line interface environment with defaults, aliases, functions, auto completion, and prompt themes.
- Install Prezto
$ git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
- Generate a new Zsh configuration by copying the files below:
- First, delete the
.zshrc
file we generated above:$ rm -rf ~/.zshrc
- And copy the preset configuration from Prezto:
$ setopt EXTENDED_GLOB for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" done
- First, delete the
- Add some modules to your
.zpreztorc
config file:# Set the Prezto modules to load (browse modules). # The order matters. zstyle ':prezto:load' pmodule \ 'environment' \ 'terminal' \ 'editor' \ 'history' \ 'directory' \ 'spectrum' \ 'utility' \ 'completion' \ 'git' \ 'prompt' \ 'syntax-highlighting' \ 'history-substring-search'
If you exit and reload your terminal, it should load Prezto.
Install Hyper, an Eletron-powered terminal.
- Download and install Windows.exe.
- Open Hyper
- Navigate to, and open, Hyper's config file:
.hyper.js
$ cd /mnt/c/Users/$USERNAME/AppData/Roaming/Hyper $ vi .hyper.js
- Ensure Hyper is pointing to
wsl.exe
:shell: 'C:\\Windows\\System32\\wsl.exe',
- Ensure Hyper launches in the WSL home (
~
). By default, it launches in the Windows user directory:shellArgs: ['~']
- If you exit and reload Hyper, you should now correctly load into Zsh at
~
. - (Optional) Update keymaps as necessary. For example:
Note that
keymaps: { "pane:splitVertical": ["ctrl+d"], "pane:splitHorizontal": ["ctrl+shift+d"], // "pane:close": ["ctrl+w"], "tab:new": ["ctrl+t"], "editor:copy": ["ctrl+shift+c"], "editor:paste": ["ctrl+shift+v"], "editor:selectAll": ["ctrl+shift+a"] },
pane:close
is commented out. As of this writing, that action crahes Hyper. Instead, run$ exit
to close a pane. - (Optional) Open PowerShell and install the
hyper-material-theme
theme:> hyper install hyper-material-theme
- (Optional) Open PowerShell and install the
hyper-pane
plugin to enhance pane navigation:> hyper install hyper-pane
Exit and reload Hyper or do a hard reload (ctrl+shift+r
by default).
Install Node.js. Two possible paths are provided.
Leveraging the Node Version Manager (nvm) makes this seamless and straight forward.
- Install nvm using the install script found here and pipe it to
zsh
:$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | zsh
- Remove the following line from
~/.zshrc
:If you see the following error:[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
zsh compinit: insecure directories, run compaudit for list.
- Exit and reload your shell.
- Install the latest version of Node.js:
$ nvm install 12.7.0
- Ensure that both
node
andnpm
are available:$ node --version $ npm --version
Volta is a viable alternative to nvm that simplifies version management for your tools. Check it out at volta.sh:
- Install Volta:
$ curl https://get.volta.sh | bash
- Install Node.js:
$ volta install node
- Ensure that
node
is available:$ node --version
Follow the Linux steps outlined in GitHub's Generating a new SSH key and adding it to the ssh-agent guide.
Git should already be installed. You can verify this by running $ git --version
.
If your git is out of date, you can upgrade it to the latest version:
$ sudo add-apt-repository ppa:git-core/ppa -y
$ sudo apt-get update
$ sudo apt-get install git -y
Add some reasonable aliases:
- Open
~/.gitconfig
. - Add some reasonable aliases to improve your developer experience:
[alias] alias = !git config --list | grep 'alias' | sort co = !git checkout $* && echo "Checked out:" st = !git status cp = !git cherry-pick p = !git fetch --tags --all && git pull --rebase pp = !git p && git push last = !git log -1 HEAD wipe = !git clean -xfd && git reset HEAD --hard
Optionally install a helpful shell utility - autojump
- to more quickly navigate your filesystem:
- Install
autojump
:$ sudo apt-get install autojump
- Configure zsh to source startup script by adding the following to you
~/.zshrc
:# Source autojump if [[ -s "/usr/share/autojump/autojump.sh" ]]; then source "/usr/share/autojump/autojump.sh" fi
If for whatever reason you wish to uninstall the Windows Subsystem for Linux (WSL), simply open up Windows PowerShell and run the following command:
$ wslconfig.exe /u <DISTRIBUTION_NAME>
Where <DISTRIBUTION_NAME>
matches an installed distro (e.g. Ubuntu
). If you are not sure which you have installed, use /list /all
.