mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-25 12:24:47 +02:00
Running WSL without a container would be treated as native linux, causing problems at it would then attempt to use `xdg-open`. This was caused by `isContainer()` always returning true due to some dubious conditionals. These have been removed. The env-var check seems to not be used by lazygit, nor any common containers, and therefore appears to only exist to manually tell lazygit to behave as if it were inside of a container. This functionality has been kept, but the env-var has been changed to be all uppercaps as to comply with the POSIX standard. Fixes #2757 Bug introduced in 4d78d76
34 lines
818 B
Go
34 lines
818 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func isWSL() bool {
|
|
data, err := os.ReadFile("/proc/sys/kernel/osrelease")
|
|
return err == nil && strings.Contains(string(data), "microsoft")
|
|
}
|
|
|
|
func isContainer() bool {
|
|
data, err := os.ReadFile("/proc/1/cgroup")
|
|
return err == nil && (strings.Contains(string(data), "docker") ||
|
|
strings.Contains(string(data), "/lxc/") ||
|
|
os.Getenv("CONTAINER") != "")
|
|
}
|
|
|
|
// GetPlatformDefaultConfig gets the defaults for the platform
|
|
func GetPlatformDefaultConfig() OSConfig {
|
|
if isWSL() && !isContainer() {
|
|
return OSConfig{
|
|
Open: `powershell.exe start explorer.exe {{filename}} >/dev/null`,
|
|
OpenLink: `powershell.exe start {{link}} >/dev/null`,
|
|
}
|
|
}
|
|
|
|
return OSConfig{
|
|
Open: `xdg-open {{filename}} >/dev/null`,
|
|
OpenLink: `xdg-open {{link}} >/dev/null`,
|
|
}
|
|
}
|