Skip to content

Commit dbd407c

Browse files
committed
Use interactive shell for running shell commands only if shell is bash or zsh
We use an interactive shell so that users can use their custom shell aliases in lazygit's shell prompt, which is convenient; however, this only really works for shells like bash or zsh. We know it doesn't work for fish or nushell (because these use different names for the $? variable); so use an interactive shell only if the user's shell is either bash or zsh.
1 parent b8d5e48 commit dbd407c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pkg/commands/oscommands/os_default_platform.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,29 @@ package oscommands
66
import (
77
"os"
88
"runtime"
9+
"strings"
910
)
1011

1112
func GetPlatform() *Platform {
13+
shell := getUserShell()
14+
15+
interactiveShell := shell
16+
interactiveShellArg := "-i"
17+
interactiveShellExit := "; exit $?"
18+
19+
if !(strings.HasSuffix(shell, "bash") || strings.HasSuffix(shell, "zsh")) {
20+
interactiveShell = "bash"
21+
interactiveShellArg = ""
22+
interactiveShellExit = ""
23+
}
24+
1225
return &Platform{
1326
OS: runtime.GOOS,
1427
Shell: "bash",
15-
InteractiveShell: getUserShell(),
28+
InteractiveShell: interactiveShell,
1629
ShellArg: "-c",
17-
InteractiveShellArg: "-i",
18-
InteractiveShellExit: "; exit $?",
30+
InteractiveShellArg: interactiveShellArg,
31+
InteractiveShellExit: interactiveShellExit,
1932
OpenCommand: "open {{filename}}",
2033
OpenLinkCommand: "open {{link}}",
2134
}

0 commit comments

Comments
 (0)