diff --git a/pkg/gui/services/custom_commands/handler_creator.go b/pkg/gui/services/custom_commands/handler_creator.go index b5c2b9efd..6ac9fb733 100644 --- a/pkg/gui/services/custom_commands/handler_creator.go +++ b/pkg/gui/services/custom_commands/handler_creator.go @@ -1,6 +1,8 @@ package custom_commands import ( + "strings" + "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" @@ -191,8 +193,15 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses if err != nil { return self.c.Error(err) } + if customCommand.ShowOutput { - return self.c.Alert(cmdStr, output) + if strings.TrimSpace(output) == "" { + output = self.c.Tr.EmptyOutput + } + if err = self.c.Alert(cmdStr, output); err != nil { + return self.c.Error(err) + } + return self.c.Refresh(types.RefreshOptions{}) } return self.c.Refresh(types.RefreshOptions{}) }) diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index af5a8a99b..be771d813 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -501,6 +501,7 @@ type TranslationSet struct { UpstreamGone string NukeDescription string DiscardStagedChangesDescription string + EmptyOutput string Actions Actions Bisect Bisect } @@ -1136,6 +1137,7 @@ func EnglishTranslationSet() TranslationSet { UpstreamGone: "(upstream gone)", NukeDescription: "If you want to make all the changes in the worktree go away, this is the way to do it. If there are dirty submodule changes this will stash those changes in the submodule(s).", DiscardStagedChangesDescription: "This will create a new stash entry containing only staged files and then drop it, so that the working tree is left with only unstaged changes", + EmptyOutput: "", Actions: Actions{ // TODO: combine this with the original keybinding descriptions (those are all in lowercase atm) CheckoutCommit: "Checkout commit",