1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-23 12:18:51 +02:00
lazygit/pkg/commands/oscommands/os_default_platform.go
Stefan Haller f28b6f439d Support fish when running shell command
This should allow using custom shell functions in lazygit's : prompt.
2025-03-06 08:11:32 +01:00

46 lines
959 B
Go

//go:build !windows
// +build !windows
package oscommands
import (
"os"
"runtime"
"strings"
)
func GetPlatform() *Platform {
shell := getUserShell()
interactiveShell := shell
interactiveShellArg := "-i"
interactiveShellExit := "; exit $?"
if strings.HasSuffix(shell, "fish") {
interactiveShellExit = "; exit $status"
} else if !(strings.HasSuffix(shell, "bash") || strings.HasSuffix(shell, "zsh")) {
interactiveShell = "bash"
interactiveShellArg = ""
interactiveShellExit = ""
}
return &Platform{
OS: runtime.GOOS,
Shell: "bash",
InteractiveShell: interactiveShell,
ShellArg: "-c",
InteractiveShellArg: interactiveShellArg,
InteractiveShellExit: interactiveShellExit,
OpenCommand: "open {{filename}}",
OpenLinkCommand: "open {{link}}",
}
}
func getUserShell() string {
if shell := os.Getenv("SHELL"); shell != "" {
return shell
}
return "bash"
}