Skip to content

Instantly share code, notes, and snippets.

@anindex
Last active January 13, 2021 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anindex/c83695819be71077faad1d83f35c0fca to your computer and use it in GitHub Desktop.
Save anindex/c83695819be71077faad1d83f35c0fca to your computer and use it in GitHub Desktop.

Install WSL

Follow https://wiki.ubuntu.com/WSL

Setup the environment

WSL side

Edit ~\.bash_profile:

if [[ -f ~/.bashrc ]] ; then
        . ~/.bashrc
fi
PATH=~/.local/bin:$PATH

Append ~\.bashrc: # this is for using graphical X server

export DISPLAY=$WSL_IF_IP:0
unset LIBGL_ALWAYS_INDIRECT

Then:

sudo apt update && sudo apt upgrade

Window side

Install vcXsrv then add this enable_xming.bat to starup at C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup:

@ECHO OFF

REM Start WSL once to create WSL netowrk interface
wsl exit

REM Find IP for WSL network interface
SET WSL_IF_IP=
CALL :GetIp "vEthernet (WSL)" WSL_IF_IP
ECHO WSL_IF_IP=%WSL_IF_IP%
setx "WSL_IF_IP" "%WSL_IF_IP%"
setx "WSLENV" "WSL_IF_IP/u"

REM Change E:\VcXsrv to your VcXsrv installation folder
START /D "C:\Program Files\VcXsrv" /B vcxsrv.exe -multiwindow -clipboard -nowgl -ac -displayfd 720
GOTO :EOF



:GetIp ( aInterface , aIp )
(
    SETLOCAL EnableExtensions EnableDelayedExpansion
    FOR /f "tokens=3 delims=: " %%i IN ('netsh interface ip show address "%~1" ^| findstr IP') DO (
        SET RET=%%i
    )
)
(
    ENDLOCAL
    SET "%~2=%RET%"
    EXIT /B
)

Reference: microsoft/WSL#4793

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment