Pretty straightforward, the usual places to figure out the OS you\'re on seem to be identical to plain Ubuntu on Ubuntu for Windows. For example uname -a
is ide
Without me doing anything special, these environment variables seem to be set already:
$ set | grep WSL
IS_WSL='Linux version 4.4.0-18362-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #1-Microsoft Mon Mar 18 12:02:00 PST 2019'
WSLENV=
WSL_DISTRO_NAME=Debian
So, something like the following snippet should also work in this case (example of what I used it for myself):
if [ ! -z "$IS_WSL" ]; then
alias code='/mnt/c/Users/per/AppData/Local/Programs/Microsoft\ VS\ Code/Code.exe'
fi
(Note that technically, -z does not check if the variable is unset, merely that it is empty; in practice, this works well enough in this case. The !
at the beginning is there to negate the check.)