Skip to content

Commit b09251e

Browse files
authored
Merge branch 'master' into fix-display-of-renamed-files-in-tree-view
2 parents b0b8ef9 + 6fb7942 commit b09251e

File tree

83 files changed

+1007
-317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1007
-317
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Press `b` in the commits view to mark a commit as good/bad in order to begin a g
148148

149149
### Nuke the working tree
150150

151-
For when you really want to just get rid of anything that shows up when you run `git status` (and yes that includes dirty submodules) [kidpix style](https://www.youtube.com/watch?v=Ur7_A4JusMU), press `shift+d` to bring up the reset options menu and then select the 'nuke' option.
151+
For when you really want to just get rid of anything that shows up when you run `git status` (and yes that includes dirty submodules) [kidpix style](https://www.youtube.com/watch?v=N4E2B_k2Bss), press `shift+d` to bring up the reset options menu and then select the 'nuke' option.
152152

153153
![Nuke working tree](../assets/demo/nuke_working_tree-compressed.gif)
154154

docs/Config.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ os:
442442
# See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#custom-command-for-copying-to-and-pasting-from-clipboard
443443
readFromClipboardCmd: ""
444444

445+
# A shell startup file containing shell aliases or shell functions. This will be sourced before running any shell commands, so that shell functions are available in the `:` command prompt or even in custom commands.
446+
# See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#using-aliases-or-functions-in-shell-commands
447+
shellFunctionsFile: ""
448+
445449
# If true, don't display introductory popups upon opening Lazygit.
446450
disableStartupPopups: false
447451

@@ -740,6 +744,21 @@ The `editInTerminal` option is used to decide whether lazygit needs to suspend i
740744

741745
Contributions of new editor presets are welcome; see the `getPreset` function in [`editor_presets.go`](https://github.com/jesseduffield/lazygit/blob/master/pkg/config/editor_presets.go).
742746

747+
## Using aliases or functions in shell commands
748+
749+
Lazygit has a command prompt (`:`) for quickly executing shell commands without having to quit lazygit or switch to a different terminal. Most people find it convenient to have their usual shell aliases or shell functions available at this prompt. To achieve this, put your alias definitions in a separate shell startup file (which you source from your normal startup file, i.e. from `.bashrc` or `.zshrc`), and then tell lazygit about this file like so:
750+
751+
```yml
752+
os:
753+
shellFunctionsFile: ~/.my_aliases.sh
754+
```
755+
756+
For many people it might work well enough to use their entire shell config file (`~/.bashrc` or `~/.zshrc`) as the `shellFunctionsFile`, but these config files typically do a lot more than defining aliases (e.g. initialize the completion system, start an ssh-agent, etc.) and this may unnecessarily delay execution of shell commands.
757+
758+
When using zsh, aliases can't be used here, but functions can. It is easy to convert your existing aliases into functions, just change `alias l="ls -la"` to `l() ls -la`, for example. This way it will work as before both in the shell and in lazygit.
759+
760+
Note that the shell aliases file is not only used when executing shell commands, but also for [custom commands](Custom_Command_Keybindings.md), and when opening a file in the editor.
761+
743762
## Overriding default config file location
744763

745764
To override the default config directory, use `CONFIG_DIR="$HOME/.config/lazygit"`. This directory contains the config file in addition to some other files lazygit uses to keep track of state across sessions.

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ require (
1313
github.com/gookit/color v1.4.2
1414
github.com/imdario/mergo v0.3.11
1515
github.com/integrii/flaggy v1.4.0
16-
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68
16+
github.com/jesseduffield/generics v0.0.0-20250406224309-4f541cb84918
1717
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d
18-
github.com/jesseduffield/gocui v0.3.1-0.20250220081214-b376cb0857ac
18+
github.com/jesseduffield/gocui v0.3.1-0.20250408140206-7f1bb9232647
1919
github.com/jesseduffield/kill v0.0.0-20250101124109-e216ddbe133a
2020
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5
2121
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e
@@ -37,7 +37,7 @@ require (
3737
github.com/stretchr/testify v1.8.1
3838
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778
3939
golang.org/x/exp v0.0.0-20220318154914-8dddf5d87bd8
40-
golang.org/x/sync v0.11.0
40+
golang.org/x/sync v0.13.0
4141
gopkg.in/ozeidan/fuzzy-patricia.v3 v3.0.0
4242
gopkg.in/yaml.v3 v3.0.1
4343
)
@@ -73,8 +73,8 @@ require (
7373
github.com/xanzy/ssh-agent v0.2.1 // indirect
7474
golang.org/x/crypto v0.31.0 // indirect
7575
golang.org/x/net v0.33.0 // indirect
76-
golang.org/x/sys v0.30.0 // indirect
77-
golang.org/x/term v0.29.0 // indirect
78-
golang.org/x/text v0.22.0 // indirect
76+
golang.org/x/sys v0.32.0 // indirect
77+
golang.org/x/term v0.31.0 // indirect
78+
golang.org/x/text v0.24.0 // indirect
7979
gopkg.in/warnings.v0 v0.1.2 // indirect
8080
)

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,12 @@ github.com/invopop/jsonschema v0.10.0 h1:c1ktzNLBun3LyQQhyty5WE3lulbOdIIyOVlkmDL
182182
github.com/invopop/jsonschema v0.10.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
183183
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
184184
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
185-
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 h1:EQP2Tv8TIcC6Y4RI+1ZbJDOHfGJ570tPeYVCqo7/tws=
186-
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68/go.mod h1:+LLj9/WUPAP8LqCchs7P+7X0R98HiFujVFANdNaxhGk=
185+
github.com/jesseduffield/generics v0.0.0-20250406224309-4f541cb84918 h1:meoUDZGF6jZAbhW5IBwj92mTqGmrOn+Cuu0jM7/aUcs=
186+
github.com/jesseduffield/generics v0.0.0-20250406224309-4f541cb84918/go.mod h1:+LLj9/WUPAP8LqCchs7P+7X0R98HiFujVFANdNaxhGk=
187187
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d h1:bO+OmbreIv91rCe8NmscRwhFSqkDJtzWCPV4Y+SQuXE=
188188
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o=
189-
github.com/jesseduffield/gocui v0.3.1-0.20250220081214-b376cb0857ac h1:vUNTiVEB9Bz16pTJ5kNgb/1HhnWdSA1P0GfFLUJeITI=
190-
github.com/jesseduffield/gocui v0.3.1-0.20250220081214-b376cb0857ac/go.mod h1:sLIyZ2J42R6idGdtemZzsiR3xY5EF0KsvYEGh3dQv3s=
189+
github.com/jesseduffield/gocui v0.3.1-0.20250408140206-7f1bb9232647 h1:XpoXCyLGCB4mczPc1q/8dJefr6OB1xa7jyhH5a5eJqY=
190+
github.com/jesseduffield/gocui v0.3.1-0.20250408140206-7f1bb9232647/go.mod h1:sLIyZ2J42R6idGdtemZzsiR3xY5EF0KsvYEGh3dQv3s=
191191
github.com/jesseduffield/kill v0.0.0-20250101124109-e216ddbe133a h1:UDeJ3EBk04bXDLOPvuqM3on8HvyJfISw0+UMqW+0a4g=
192192
github.com/jesseduffield/kill v0.0.0-20250101124109-e216ddbe133a/go.mod h1:FSWDLKT0NQpntbDd1H3lbz51fhCVlMzy/J0S6nM727Q=
193193
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 h1:CDuQmfOjAtb1Gms6a1p5L2P8RhbLUq5t8aL7PiQd2uY=
@@ -436,8 +436,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
436436
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
437437
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
438438
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
439-
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
440-
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
439+
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
440+
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
441441
golang.org/x/sys v0.0.0-20170407050850-f3918c30c5c2/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
442442
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
443443
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -491,8 +491,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
491491
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
492492
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
493493
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
494-
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
495-
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
494+
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
495+
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
496496
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
497497
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
498498
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -502,8 +502,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
502502
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
503503
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
504504
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
505-
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
506-
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
505+
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o=
506+
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
507507
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
508508
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
509509
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -518,8 +518,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
518518
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
519519
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
520520
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
521-
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
522-
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
521+
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
522+
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
523523
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
524524
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
525525
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

pkg/commands/git_cmd_obj_builder.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@ func (self *gitCmdObjBuilder) New(args []string) oscommands.ICmdObj {
3434
return self.innerBuilder.New(args).AddEnvVars(defaultEnvVar)
3535
}
3636

37-
func (self *gitCmdObjBuilder) NewShell(cmdStr string) oscommands.ICmdObj {
38-
return self.innerBuilder.NewShell(cmdStr).AddEnvVars(defaultEnvVar)
39-
}
40-
41-
func (self *gitCmdObjBuilder) NewInteractiveShell(cmdStr string) oscommands.ICmdObj {
42-
return self.innerBuilder.NewInteractiveShell(cmdStr).AddEnvVars(defaultEnvVar)
37+
func (self *gitCmdObjBuilder) NewShell(cmdStr string, shellFunctionsFile string) oscommands.ICmdObj {
38+
return self.innerBuilder.NewShell(cmdStr, shellFunctionsFile).AddEnvVars(defaultEnvVar)
4339
}
4440

4541
func (self *gitCmdObjBuilder) Quote(str string) string {

pkg/commands/oscommands/cmd_obj_builder.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ type ICmdObjBuilder interface {
1313
// NewFromArgs takes a slice of strings like []string{"git", "commit"} and returns a new command object.
1414
New(args []string) ICmdObj
1515
// NewShell takes a string like `git commit` and returns an executable shell command for it e.g. `sh -c 'git commit'`
16-
NewShell(commandStr string) ICmdObj
17-
// Like NewShell, but uses the user's shell rather than "bash", and passes -i to it
18-
NewInteractiveShell(commandStr string) ICmdObj
16+
// shellFunctionsFile is an optional file path that will be sourced before executing the command. Callers should pass
17+
// the value of UserConfig.OS.ShellFunctionsFile.
18+
NewShell(commandStr string, shellFunctionsFile string) ICmdObj
1919
// Quote wraps a string in quotes with any necessary escaping applied. The reason for bundling this up with the other methods in this interface is that we basically always need to make use of this when creating new command objects.
2020
Quote(str string) string
2121
}
@@ -44,20 +44,16 @@ func (self *CmdObjBuilder) NewWithEnviron(args []string, env []string) ICmdObj {
4444
}
4545
}
4646

47-
func (self *CmdObjBuilder) NewShell(commandStr string) ICmdObj {
47+
func (self *CmdObjBuilder) NewShell(commandStr string, shellFunctionsFile string) ICmdObj {
48+
if len(shellFunctionsFile) > 0 {
49+
commandStr = fmt.Sprintf("%ssource %s\n%s", self.platform.PrefixForShellFunctionsFile, shellFunctionsFile, commandStr)
50+
}
4851
quotedCommand := self.quotedCommandString(commandStr)
4952
cmdArgs := str.ToArgv(fmt.Sprintf("%s %s %s", self.platform.Shell, self.platform.ShellArg, quotedCommand))
5053

5154
return self.New(cmdArgs)
5255
}
5356

54-
func (self *CmdObjBuilder) NewInteractiveShell(commandStr string) ICmdObj {
55-
quotedCommand := self.quotedCommandString(commandStr + self.platform.InteractiveShellExit)
56-
cmdArgs := str.ToArgv(fmt.Sprintf("%s %s %s %s", self.platform.InteractiveShell, self.platform.InteractiveShellArg, self.platform.ShellArg, quotedCommand))
57-
58-
return self.New(cmdArgs)
59-
}
60-
6157
func (self *CmdObjBuilder) quotedCommandString(commandStr string) string {
6258
// Windows does not seem to like quotes around the command
6359
if self.platform.OS == "windows" {

pkg/commands/oscommands/dummies.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,11 @@ func NewDummyCmdObjBuilder(runner ICmdObjRunner) *CmdObjBuilder {
5151
}
5252

5353
var dummyPlatform = &Platform{
54-
OS: "darwin",
55-
Shell: "bash",
56-
InteractiveShell: "bash",
57-
ShellArg: "-c",
58-
InteractiveShellArg: "-i",
59-
InteractiveShellExit: "; exit $?",
60-
OpenCommand: "open {{filename}}",
61-
OpenLinkCommand: "open {{link}}",
54+
OS: "darwin",
55+
Shell: "bash",
56+
ShellArg: "-c",
57+
OpenCommand: "open {{filename}}",
58+
OpenLinkCommand: "open {{link}}",
6259
}
6360

6461
func NewDummyOSCommandWithRunner(runner *FakeCmdObjRunner) *OSCommand {

pkg/commands/oscommands/os.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ type OSCommand struct {
3535

3636
// Platform stores the os state
3737
type Platform struct {
38-
OS string
39-
Shell string
40-
InteractiveShell string
41-
ShellArg string
42-
InteractiveShellArg string
43-
InteractiveShellExit string
44-
OpenCommand string
45-
OpenLinkCommand string
38+
OS string
39+
Shell string
40+
ShellArg string
41+
PrefixForShellFunctionsFile string
42+
OpenCommand string
43+
OpenLinkCommand string
4644
}
4745

4846
// NewOSCommand os command runner
@@ -93,7 +91,7 @@ func (c *OSCommand) OpenFile(filename string) error {
9391
"filename": c.Quote(filename),
9492
}
9593
command := utils.ResolvePlaceholderString(commandTemplate, templateValues)
96-
return c.Cmd.NewShell(command).Run()
94+
return c.Cmd.NewShell(command, c.UserConfig().OS.ShellFunctionsFile).Run()
9795
}
9896

9997
func (c *OSCommand) OpenLink(link string) error {
@@ -110,7 +108,7 @@ func (c *OSCommand) OpenLink(link string) error {
110108
}
111109

112110
command := utils.ResolvePlaceholderString(commandTemplate, templateValues)
113-
return c.Cmd.NewShell(command).Run()
111+
return c.Cmd.NewShell(command, c.UserConfig().OS.ShellFunctionsFile).Run()
114112
}
115113

116114
// Quote wraps a message in platform-specific quotation marks
@@ -299,7 +297,7 @@ func (c *OSCommand) CopyToClipboard(str string) error {
299297
cmdStr := utils.ResolvePlaceholderString(c.UserConfig().OS.CopyToClipboardCmd, map[string]string{
300298
"text": c.Cmd.Quote(str),
301299
})
302-
return c.Cmd.NewShell(cmdStr).Run()
300+
return c.Cmd.NewShell(cmdStr, c.UserConfig().OS.ShellFunctionsFile).Run()
303301
}
304302

305303
return clipboard.WriteAll(str)
@@ -310,7 +308,7 @@ func (c *OSCommand) PasteFromClipboard() (string, error) {
310308
var err error
311309
if c.UserConfig().OS.CopyToClipboardCmd != "" {
312310
cmdStr := c.UserConfig().OS.ReadFromClipboardCmd
313-
s, err = c.Cmd.NewShell(cmdStr).RunWithOutput()
311+
s, err = c.Cmd.NewShell(cmdStr, c.UserConfig().OS.ShellFunctionsFile).RunWithOutput()
314312
} else {
315313
s, err = clipboard.ReadAll()
316314
}
@@ -360,5 +358,5 @@ func (c *OSCommand) UpdateWindowTitle() error {
360358
return getWdErr
361359
}
362360
argString := fmt.Sprint("title ", filepath.Base(path), " - Lazygit")
363-
return c.Cmd.NewShell(argString).Run()
361+
return c.Cmd.NewShell(argString, c.UserConfig().OS.ShellFunctionsFile).Run()
364362
}

pkg/commands/oscommands/os_default_platform.go

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,18 @@ import (
1212
func GetPlatform() *Platform {
1313
shell := getUserShell()
1414

15-
interactiveShell := shell
16-
interactiveShellArg := "-i"
17-
interactiveShellExit := "; exit $?"
18-
19-
if strings.HasSuffix(shell, "fish") {
20-
interactiveShellExit = "; exit $status"
21-
} else if !(strings.HasSuffix(shell, "bash") || strings.HasSuffix(shell, "zsh")) {
22-
interactiveShell = "bash"
23-
interactiveShellArg = ""
24-
interactiveShellExit = ""
15+
prefixForShellFunctionsFile := ""
16+
if strings.HasSuffix(shell, "bash") {
17+
prefixForShellFunctionsFile = "shopt -s expand_aliases\n"
2518
}
2619

2720
return &Platform{
28-
OS: runtime.GOOS,
29-
Shell: "bash",
30-
InteractiveShell: interactiveShell,
31-
ShellArg: "-c",
32-
InteractiveShellArg: interactiveShellArg,
33-
InteractiveShellExit: interactiveShellExit,
34-
OpenCommand: "open {{filename}}",
35-
OpenLinkCommand: "open {{link}}",
21+
OS: runtime.GOOS,
22+
Shell: shell,
23+
ShellArg: "-c",
24+
PrefixForShellFunctionsFile: prefixForShellFunctionsFile,
25+
OpenCommand: "open {{filename}}",
26+
OpenLinkCommand: "open {{link}}",
3627
}
3728
}
3829

pkg/commands/oscommands/os_windows.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ package oscommands
22

33
func GetPlatform() *Platform {
44
return &Platform{
5-
OS: "windows",
6-
Shell: "cmd",
7-
InteractiveShell: "cmd",
8-
ShellArg: "/c",
9-
InteractiveShellArg: "",
10-
InteractiveShellExit: "",
5+
OS: "windows",
6+
Shell: "cmd",
7+
ShellArg: "/c",
118
}
129
}

0 commit comments

Comments
 (0)