This is a constant work in progress.
Because I became so accustom to having bash behind my VSCode app to run linux-like commands on my MacBookPro and now that I don't have or want another MacBook variant, I want to be able to have a linux-like command system behind visual studio code.
Why not just use linux? Because I use a lot of apps that don't run on linux.
Why not just have a Mac? OSX gets worse and worse as time goes on and the keyboards, lightbar and complete lack of ports drives me nuts.
I have 3 development focuses:
- Working soley in VSCode/Docker
- I checkout using git to the wsl file system
- I use VSCode's integration with WSL to edit everything
- Working mostly in VSCode but using other local IDE's like Arduino, OpenSCAD or similar
- I checkout and edit in Windows (with git bash)
- I use windows native stuff
- Working only in Windows, e.g. Android, Unity or .net dev
- I checkout and edit in Windows (with git bash)
- I use windows native apps
First off WSL2 is better than 1, install WSL2. You will need to be on Windows 10 2004 or newer.
Then install Ubuntu from the Microsoft app store.
A bit of powershell is all you need.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
wsl --set-default-version 2
wsl --set-version ubuntu 2
wsl shutdown
There's some weird things with pathing, by default, all drives including C
are mounted in /mnt
but for docker (and other things) to play nice we need to change c to be mounted in /
- edit the /etc/wsl.conf
(sudo)
sudo vim /etc/wsl.conf
This file should look like this.
[automount]
enabled = true
crossDistro = true
root = /
For one reason or another you may want to ssh into your wsl2 instance from another computer on the network.
First, configure ssh to use a higher port - this is because windows has an ssh service running, i am not sur ehow to utilize it so i just circumvent it. I chose port 2222.
Put this line in the /etc/ssh/sshd_config
file (ubuntu)
Port 2222
Then start the ssh server:
sudo service ssh start
Next open the port in windows, note the -Profile 'Private'
point means only allowing access from your local network, run this in an elevated powershell.
New-NetFirewallRule -DisplayName 'SSH to WSL' -Profile 'Private' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 2222
Now create a proxy to the port in windows, run this in an elevated powershell.
netsh interface portproxy add v4tov4 listenport=2222 listenaddress=0.0.0.0 connectport=2222 connectaddress=127.0.0.1
You may need to start ssh every time you reboot, i have left it this way as i don't ssh in much.
As of WSL2 you can run docker inside the wsl container/vm which is awesome.
Also to log into dockerhub (so you can push images) you will need to install pass
sudo apt install gnupg2 pass
WSL2 deals with file attributes in windows pretty well but it's not 100% and it may never be, Windows and linux filesystems are simply different.
I keep git repos either Windows or WSL, if it's webdev or anyting that I'm doing in VSCode, I usually clone it in WSL and leave it there. If it needs the GPU or if it's a windows or android app, it's better to clone code in Windows and commit there.
Also, don't forget about line endings....
If you want to besure your IDE's do not use crlf
and use only lf
- code pushes the line endings sometimes - you may need to run this in all your shells on WSL and on Windows (Powershell, gitbash, command line etc.
git config --global core.autocrlf false
git config --global core.eol lf
If you have trouble with the execute bit getting missed... you will have to run this in every repo that's a problem.
git config --global core.fileMode false
Of course install AWS cli.
pip install awscli
I use stackup
quite a bit:
sudo gem install stackup
By default, wsl/ubuntu has python2.7.x as it's default python instance.
To get around this, i want to use pyenv sourced from here
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
curl https://pyenv.run | bash
put this in your ~/.profile
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv install 3.7.4
pyenv global 3.7.4
- [SSH and autostarting] (https://gist.github.com/dentechy/de2be62b55cfd234681921d5a8b6be11)
- [Docker on WSL] (https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly)
- windows firewall
Other useful links
- getting rid of the windows photo app - I just don't like it
- Windows Photo Viewer on win 10 - I got used to the mac's lightweight preview feature
- MiniKube stuff
- More MiniKube
- More MiniKube