Skip to content

Instantly share code, notes, and snippets.

@jeromescuggs
Created November 9, 2020 21:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeromescuggs/548cc7bf3accc277d427fa263720957f to your computer and use it in GitHub Desktop.
Save jeromescuggs/548cc7bf3accc277d427fa263720957f to your computer and use it in GitHub Desktop.
flawless WSL compatibility with X servers (x410, VcXsrv etc) for .zshrc
# WSL1 compatibility with X server (x410, others should work)
if [[ "$(</proc/version)" == *Microsoft* ]] 2>/dev/null; then
export WSL=1
export DISPLAY=localhost:0
export NO_AT_BRIDGE=1
export LIBGL_ALWAYS_INDIRECT=1
fi
# WSL2 compatibility
if [[ "$(</proc/version)" == *microsoft* ]] 2>/dev/null; then
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0
export LIBGL_ALWAYS_INDIRECT
fi
@mirzalazuardi
Copy link

mirzalazuardi commented Dec 16, 2021

wow.... this is really i searching for long time. thanks a lot @jeromescuggs

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