2018-09-01 14:33:01 +10:00
|
|
|
package config
|
|
|
|
|
2022-06-11 23:18:29 -07:00
|
|
|
import (
|
2022-06-11 23:23:22 -07:00
|
|
|
"io/ioutil"
|
|
|
|
"strings"
|
2022-06-11 23:18:29 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func isWSL() bool {
|
2022-06-11 23:23:22 -07:00
|
|
|
data, err := ioutil.ReadFile("/proc/sys/kernel/osrelease")
|
|
|
|
return err == nil && strings.Contains(string(data), "microsoft")
|
2022-06-11 23:18:29 -07:00
|
|
|
}
|
|
|
|
|
2018-09-01 14:33:01 +10:00
|
|
|
// GetPlatformDefaultConfig gets the defaults for the platform
|
2020-10-03 14:54:55 +10:00
|
|
|
func GetPlatformDefaultConfig() OSConfig {
|
2022-06-11 23:23:22 -07:00
|
|
|
if isWSL() {
|
|
|
|
return OSConfig{
|
|
|
|
EditCommand: ``,
|
|
|
|
EditCommandTemplate: "",
|
|
|
|
OpenCommand: `powershell.exe start explorer.exe {{filename}} >/dev/null`,
|
2022-07-03 02:00:40 -07:00
|
|
|
OpenLinkCommand: `powershell.exe start {{link}} >/dev/null`,
|
2022-06-11 23:23:22 -07:00
|
|
|
}
|
|
|
|
}
|
2022-06-11 23:18:29 -07:00
|
|
|
|
2020-10-03 14:54:55 +10:00
|
|
|
return OSConfig{
|
2021-08-04 18:43:34 +09:00
|
|
|
EditCommand: ``,
|
2022-04-22 21:54:03 +09:00
|
|
|
EditCommandTemplate: "",
|
2021-10-09 16:32:36 +09:00
|
|
|
OpenCommand: `xdg-open {{filename}} >/dev/null`,
|
|
|
|
OpenLinkCommand: `xdg-open {{link}} >/dev/null`,
|
2020-10-03 14:54:55 +10:00
|
|
|
}
|
2018-09-01 14:33:01 +10:00
|
|
|
}
|