From 3067c2c321c46260bcfb571ff82a9fcecb0c0a7b Mon Sep 17 00:00:00 2001 From: John Shin Date: Sat, 11 Jun 2022 23:18:29 -0700 Subject: [PATCH 1/3] support open file and link on WSL --- pkg/config/config_linux.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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: "", From 4d54b3801f1061b22f4fdcd5c6737c30c64efcde Mon Sep 17 00:00:00 2001 From: John Shin Date: Sat, 11 Jun 2022 23:23:22 -0700 Subject: [PATCH 2/3] apply formatting --- pkg/config/config_linux.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/config/config_linux.go b/pkg/config/config_linux.go index b406e875e..a52602447 100644 --- a/pkg/config/config_linux.go +++ b/pkg/config/config_linux.go @@ -1,26 +1,26 @@ package config import ( - "io/ioutil" - "strings" + "io/ioutil" + "strings" ) func isWSL() bool { - data, err := ioutil.ReadFile("/proc/sys/kernel/osrelease"); - return err == nil && strings.Contains(string(data), "microsoft") + 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`, - } - } + 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: ``, From 1eb47deae494a528ca00358eec6afafb7b3208e1 Mon Sep 17 00:00:00 2001 From: John Shin Date: Sun, 3 Jul 2022 02:00:40 -0700 Subject: [PATCH 3/3] apply gofumpt --- pkg/config/config_linux.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/config/config_linux.go b/pkg/config/config_linux.go index a52602447..8fdc0c473 100644 --- a/pkg/config/config_linux.go +++ b/pkg/config/config_linux.go @@ -12,13 +12,12 @@ func isWSL() bool { // 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`, + OpenLinkCommand: `powershell.exe start {{link}} >/dev/null`, } }