diff options
author | John Shin <shinhs0506@gmail.com> | 2022-06-11 23:18:29 -0700 |
---|---|---|
committer | John Shin <shinhs0506@gmail.com> | 2022-06-11 23:18:29 -0700 |
commit | 3067c2c321c46260bcfb571ff82a9fcecb0c0a7b (patch) | |
tree | d539c32b96001454370d56fd6243b285cc28eee7 | |
parent | 2bccbee32b285fcdec39622ec4facdf4fdb0fc02 (diff) |
support open file and link on WSL
-rw-r--r-- | pkg/config/config_linux.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/config/config_linux.go b/pkg/config/config_linux.go index b9e195f9f..b406e875e 100644 --- a/pkg/config/config_linux.go +++ b/pkg/config/config_linux.go @@ -1,7 +1,27 @@ package config +import ( + "io/ioutil" + "strings" +) + +func isWSL() bool { + data, err := ioutil.ReadFile("/proc/sys/kernel/osrelease"); + return err == nil && strings.Contains(string(data), "microsoft") +} + // GetPlatformDefaultConfig gets the defaults for the platform func GetPlatformDefaultConfig() OSConfig { + + if isWSL() { + return OSConfig{ + EditCommand: ``, + EditCommandTemplate: "", + OpenCommand: `powershell.exe start explorer.exe {{filename}} >/dev/null`, + OpenLinkCommand: `powershell.exe start {{link}} >/dev/null`, + } + } + return OSConfig{ EditCommand: ``, EditCommandTemplate: "", |