Ubuntu for Windows

Start powershell as Administrator and run:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Download and install Ubuntu for Windows via the microsoft appstore:

in Ubuntu, run:

sudo -i
apt update
apt upgrade

# install X11
apt install dbus-x11
systemd-machine-id-setup

# install a terminal app
apt install terminator

Install X11 server: https://sourceforge.net/projects/vcxsrv/

Change target in the XLaunch shortcut:

"C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto

Move the shortcut to the startup folder (open with shell:startup command).

Create a folder "C:\Program Files\Terminator" and put a text file called "startTerminator.vbs" in there:

args = "-c" & " -l " & """DISPLAY=:0 terminator"""
WScript.CreateObject("Shell.Application").ShellExecute "bash", args, "", "open", 0

Create a shortcut with target:

C:\Windows\System32\wscript.exe "C:\Program Files\Terminator\startTerminator.vbs"

Tweak the linux environment

vim .bashrc

# cd to my homedir when i open a shell
cd

Windows fonts

sudo vim /etc/fonts/local.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <dir>/mnt/c/Windows/Fonts</dir>
</fontconfig>

SSH Keys

Copy your windows ssh keys:

cp /mnt/c/Users/jorg/.ssh/id_rsa ~/.ssh/
cp /mnt/c/Users/jorg/.ssh/id_rsa.pub ~/.ssh/
chmod 600 ~/.ssh/id_rsa

Enable ssh key forwarding:

vi /etc/ssh/ssh_config

Host *
    ForwardAgent yes
    ForwardX11 yes

Install keychain

sudo apt install keychain

vi ~/.bashrc

eval `keychain --eval --agents ssh id_rsa`

Slight layout adjustment

Make the terminator tabs a bit more in-line with the windows colors:

vi .config/gtk-3.0/gtkrc

.terminator-terminal-window notebook tab {
  padding: 0;
  border: 0;
  margin: 0;
  background-color: #ccc;
}

.terminator-terminal-window notebook tab label {
  color: #000;
  font-weight: 300;
}

.terminator-terminal-window notebook tab:checked {
  background-color: #0078d7;
}

.terminator-terminal-window notebook tab:checked label {
  color: #fff;
}

Bash prompt

vi bin/auto-venv.sh

# activates the correct virtualenv, by cd-ing into the project dir
# NOTE: if the virtualenv is not located in <project>/venv, create a venv symlink pointing to the actual virtualenv

# some people prefer ".venv"
VENV_DIR="venv"

export VENV_PATH=

handle_virtualenv() {
    # search for a venv up the tree, and activate it when found
    x=`pwd`
    while [ "$x" != "/" ]; do
        if [ -e "$x/$VENV_DIR/bin/activate" ]; then
            if [ "$x" == "$VENV_PATH" ]; then
                # this venv is already activated
                break
            fi

            if [ -e "$VENV_PATH/$VENV_DIR/bin/activate" ]; then
                # deactivating previous venv
                deactivate
            fi

            # activating this venv
            VENV_PATH="$x"
            source $VENV_PATH/$VENV_DIR/bin/activate
            break
        fi
        x=`dirname "$x"`
    done

    # deactivate the venv when we're no longer in a tree with a venv
    if [ "$x" == "/" ] && [ "$VENV_PATH" != "" ]; then
        VENV_PATH=
        deactivate >/dev/null 2>&1
    fi
}

export PROMPT_COMMAND=handle_virtualenv
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.6
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true

get ~/bin/git-prompt.sh from https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh

vi .bashrc

source ~/bin/auto-venv.sh
source ~/bin/git-prompt.sh
PS1='\[\033[38;5;105m\]\u@\h\[\033[38;5;114m\] \w\[\033[38;5;221m\]$(__git_ps1 2>/dev/null)\[\033[38;5;105m\] $? \$\[\033[00m\] \033]0;$(cat /etc/hostname)\007'