Setup Bash on Windows: My environment configuration
November 17, 2016
1. Enable Bash on Windows
Bash on Windows requires the Anniversary update of Windows 10. Please make sure you have that before continuing. To determine what version of Windows you are running, open a command prompt window and type
winver. If you see Version 1607, you should be good to proceed (thanks Josh Pollard).
Once that’s all set go to
Settings -> Update & Security -> For Developers and enable
Developer mode. Finally, go to
Windows Features and enable
Windows Subsystem for Linux. Your computer should restart and you should be able to run Bash for Windows at this point.
2. Update apt-get
We are going to be installing some things and it would be good to make sure we’re up-to-date here. Launch bash by pressing the Windows key and typing
bash. From there,
apt-get update should obtain the latest package information. If you are running into issues with IPv6 vs IPv4 checkout this post on Ask Ubuntu or here on BruteForce labs.
3. Install nvm
nvm stands for Node version manager and is an essential part of my development environment. Using nvm allows you to switch what version of node you’re using on a project by project basis. To install nvm, run
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash (from the nvm documentation) followed by
4. Install git
Take the following steps to install git on Bash for Windows and be ready to work with projects on GitHub.
apt-get install git(see GitHub’s guides for more on this)
- Generate an access token or a SSH key (and associate the key to your GitHub account)
5. Setup bash git prompt
bash-git-prompt is, as the project describes, “An informative and fancy bash prompt for Git users” — that is, it shows git information for the current repository when navigating to project folder.
To install bash-git-prompt:
git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt --depth=1
Read through the documentation as there is a bit of configuration and themeing that’s possible. That said, I’m running with the default for now.
6. Make Visual Studio Code use Bash
It’s possible to toggle a terminal inside Visual Studio Code — by default, this appears to be the standard command prompt. Thankfully, Paul DeCarlo created a blog post explaining that you can add
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe" to your user settings to use Bash as the default instead.
It should look like this if everything is working correctly:
tmux is a terminal multiplexer that lets you run multiple programs in one terminal (it does a lot more than that but read the docs for more info). I frequently use tmux to run tests while running webpack server, React Storybook, or something else along those lines.
You can install tmux by running
apt-get install tmux. Once tmux is installed on the system you can press
ctrl + b + c to create a new window and
ctrl + b + w to list the windows. See this tmux cheatsheet for more
Install Ruby and Rails
I do a bit of Ruby work and highly recommend rbenv for multiple ruby versions. Digital Ocean’s guide to installing ruby / rbenv is great AND it works on Bash for Windows.
Setup vim and Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
- Setup your .vimrc (here’s my .vimrc for example)
- Run vim and type
Cmder is a nice console emulator for Windows. You can run bash in cmder by typing
bash from the prompt. You may have to type
cd ~from there to get back to your standard bash home directory.
Please feel free to let me know of any questions or feel free to submit a PR or issue on anything that’s mistaken here :)