93d9431890540dfdc1021dffca3eeebdc19d338d

Author
Marc Cornellà <marc.cornella@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

Check for Microsoft's WSL in open_command (#6751)

This will work only on files and directories in a DrvFs mount, i.e.
that can be translated to a Windows drive path.
For example: /mnt/c/Users/user.

Files and folders inside the LXSS directory can't be handled in
Windows, they must be ONLY used by the WSL subsystem. That's why
you won't be able to open your $HOME directory, for instance.

See https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/

Diff

 1diff --git a/lib/functions.zsh b/lib/functions.zsh
 2index f306537846c9662462c127dc61018dfb58bbaa5f..7410ae64553ecfebbfa467bca892d2043a2af583 100644
 3--- a/lib/functions.zsh
 4+++ b/lib/functions.zsh
 5@@ -25,7 +25,9 @@ function open_command() {
 6   case "$OSTYPE" in
 7     darwin*)  open_cmd='open' ;;
 8     cygwin*)  open_cmd='cygstart' ;;
 9-    linux*)   open_cmd='xdg-open' ;;
10+    linux*)   [[ $(uname -a) =~ "Microsoft" ]] && \
11+                open_cmd='cmd.exe /c start' || \
12+                open_cmd='xdg-open' ;;
13     msys*)    open_cmd='start ""' ;;
14     *)        echo "Platform $OSTYPE not supported"
15               return 1