mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-23 12:18:51 +02:00
Opening links containing ampersands inside lazygit (a pull-request creation page in BitBucket Server, for instance) returns the following Powershell error: > The ampersand (&) character is not allowed. The & operator is reserved > for future use; wrap an ampersand in double quotation marks ("&") to > pass it as part of a string. We fix it by enclosing the URL in single quotes.
34 lines
836 B
Go
34 lines
836 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 "$(wslpath -w {{filename}})" >/dev/null`,
|
|
OpenLink: `powershell.exe start '{{link}}' >/dev/null`,
|
|
}
|
|
}
|
|
|
|
return OSConfig{
|
|
Open: `xdg-open {{filename}} >/dev/null`,
|
|
OpenLink: `xdg-open {{link}} >/dev/null`,
|
|
}
|
|
}
|