mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-10-16 09:27:37 +03:00
- Remove old-style build tags (the +build syntax has become obsolete with 1.17) - Remove redundant build tags from '*_windows.go' files
50 lines
922 B
Go
50 lines
922 B
Go
//go:build !windows
|
|
|
|
package oscommands
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"runtime"
|
|
"strings"
|
|
"syscall"
|
|
)
|
|
|
|
func GetPlatform() *Platform {
|
|
shell := getUserShell()
|
|
|
|
prefixForShellFunctionsFile := ""
|
|
if strings.HasSuffix(shell, "bash") {
|
|
prefixForShellFunctionsFile = "shopt -s expand_aliases\n"
|
|
}
|
|
|
|
return &Platform{
|
|
OS: runtime.GOOS,
|
|
Shell: shell,
|
|
ShellArg: "-c",
|
|
PrefixForShellFunctionsFile: prefixForShellFunctionsFile,
|
|
OpenCommand: "open {{filename}}",
|
|
OpenLinkCommand: "open {{link}}",
|
|
}
|
|
}
|
|
|
|
func getUserShell() string {
|
|
if shell := os.Getenv("SHELL"); shell != "" {
|
|
return shell
|
|
}
|
|
|
|
return "bash"
|
|
}
|
|
|
|
func (c *OSCommand) UpdateWindowTitle() error {
|
|
return nil
|
|
}
|
|
|
|
func TerminateProcessGracefully(cmd *exec.Cmd) error {
|
|
if cmd.Process == nil {
|
|
return nil
|
|
}
|
|
|
|
return cmd.Process.Signal(syscall.SIGTERM)
|
|
}
|