function check_system -d 'Display short system name (OSX, Linux, Win, NA)'
  set -l osname (uname 2>/dev/null); or set -l osname (/usr/bin/uname 2>/dev/null)      # fix for lacking MSYS2 path
  if test "$osname" = Darwin
    echo OSX
  else if begin
      test (echo "$osname" | grep -E MSYS_NT 2>/dev/null)
      or test (echo "$osname" | grep -E MINGW32_NT 2>/dev/null)
      or test (echo "$osname" | grep -E MINGW64_NT 2>/dev/null)
    end
    echo Win
  else if test "$osname" = TESTLINUX
    echo Linux
  else
    echo NA
  end
end

function check_system -d 'Display short system name (OSX, Linux, Win, NA)'
  set -l osname (uname | tr '[:upper:]' '[:lower:]' 2>/dev/null); or set -l osname (fish -c "uname | tr '[:upper:]' '[:lower:]'"); or set -l osname (/usr/bin/uname | tr '[:upper:]' '[:lower:]' 2>/dev/null)
  # fix for lacking MSYS2 path; 2nd needed for WSL as regular commands fails (bug https://github.com/Microsoft/BashOnWindows/issues/1210)
  if test "$osname" = darwin
    echo OSX
  else if begin
      test (echo "$osname" | grep -E msys_nt 2>/dev/null)
      or test (echo "$osname" | grep -E mingw32_nt 2>/dev/null)
      or test (echo "$osname" | grep -E mingw64_nt 2>/dev/null)
    end
    echo Win
  else if test "$osname" = linux
    echo Linux
  else
    echo NA
  end
end

Improve OS detection, adding Windows Subsystem for Linux
Improve OS detection, adding Windows Subsystem for Linux

eugenesvk/Settings-Fish