summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/commands/files.go8
-rw-r--r--pkg/config/user_config.go2
-rw-r--r--pkg/gui/files_panel.go12
-rw-r--r--pkg/gui/keybindings.go14
-rw-r--r--pkg/i18n/english.go6
5 files changed, 42 insertions, 0 deletions
diff --git a/pkg/commands/files.go b/pkg/commands/files.go
index 579a3a252..9b4895710 100644
--- a/pkg/commands/files.go
+++ b/pkg/commands/files.go
@@ -23,6 +23,14 @@ func (c *GitCommand) CatFile(fileName string) (string, error) {
return c.OSCommand.CatFile(fileName)
}
+func (c *GitCommand) OpenMergeToolCmd() string {
+ return "git mergetool"
+}
+
+func (c *GitCommand) OpenMergeTool() error {
+ return c.OSCommand.RunCommand("git mergetool")
+}
+
// StageFile stages a file
func (c *GitCommand) StageFile(fileName string) error {
return c.RunCommand("git add -- %s", c.OSCommand.Quote(fileName))
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go
index 377ed05c0..22a31f02d 100644
--- a/pkg/config/user_config.go
+++ b/pkg/config/user_config.go
@@ -177,6 +177,7 @@ type KeybindingFilesConfig struct {
ViewResetOptions string `yaml:"viewResetOptions"`
Fetch string `yaml:"fetch"`
ToggleTreeView string `yaml:"toggleTreeView"`
+ OpenMergeTool string `yaml:"openMergeTool"`
}
type KeybindingBranchesConfig struct {
@@ -401,6 +402,7 @@ func GetDefaultConfig() *UserConfig {
ViewResetOptions: "D",
Fetch: "f",
ToggleTreeView: "`",
+ OpenMergeTool: "M",
},
Branches: KeybindingBranchesConfig{
CopyPullRequestURL: "<c-y>",
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 7d73f3d5b..f84d0c492 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -879,3 +879,15 @@ func (gui *Gui) handleToggleFileTreeView() error {
return nil
}
+
+func (gui *Gui) handleOpenMergeTool() error {
+ return gui.ask(askOpts{
+ title: gui.Tr.MergeToolTitle,
+ prompt: gui.Tr.MergeToolPrompt,
+ handleConfirm: func() error {
+ return gui.runSubprocessWithSuspenseAndRefresh(
+ gui.OSCommand.ExecutableFromString(gui.GitCommand.OpenMergeToolCmd()),
+ )
+ },
+ })
+}
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 0635280a6..ce1e53134 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -515,6 +515,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Description: gui.Tr.LcToggleTreeView,
},
{
+ ViewName: "files",
+ Contexts: []string{string(FILES_CONTEXT_KEY)},
+ Key: gui.getKey(config.Files.OpenMergeTool),
+ Handler: gui.handleOpenMergeTool,
+ Description: gui.Tr.LcOpenMergeTool,
+ },
+ {
ViewName: "branches",
Contexts: []string{string(LOCAL_BRANCHES_CONTEXT_KEY)},
Key: gui.getKey(config.Universal.Select),
@@ -1411,6 +1418,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
{
ViewName: "main",
Contexts: []string{string(MAIN_MERGING_CONTEXT_KEY)},
+ Key: gui.getKey(config.Files.OpenMergeTool),
+ Handler: gui.handleOpenMergeTool,
+ Description: gui.Tr.LcOpenMergeTool,
+ },
+ {
+ ViewName: "main",
+ Contexts: []string{string(MAIN_MERGING_CONTEXT_KEY)},
Key: gui.getKey(config.Universal.Select),
Handler: gui.handlePickHunk,
Description: gui.Tr.PickHunk,
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index 91aa18eb8..3b9ce3377 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -48,6 +48,7 @@ type TranslationSet struct {
LcToggleStaged string
LcToggleStagedAll string
LcToggleTreeView string
+ LcOpenMergeTool string
LcRefresh string
LcPush string
LcPull string
@@ -156,6 +157,8 @@ type TranslationSet struct {
CouldNotFindBinaryErr string
AnonymousReportingTitle string
AnonymousReportingPrompt string
+ MergeToolTitle string
+ MergeToolPrompt string
IntroPopupMessage string
GitconfigParseErr string
LcEditFile string
@@ -683,6 +686,7 @@ func englishTranslationSet() TranslationSet {
LcToggleStaged: "toggle staged",
LcToggleStagedAll: "stage/unstage all",
LcToggleTreeView: "toggle file tree view",
+ LcOpenMergeTool: "open external merge tool (git mergetool)",
LcRefresh: "refresh",
LcPush: "push",
LcPull: "pull",
@@ -791,6 +795,8 @@ func englishTranslationSet() TranslationSet {
CouldNotFindBinaryErr: "Could not find any binary at {{.url}}",
AnonymousReportingTitle: "Help make lazygit better",
AnonymousReportingPrompt: "Would you like to enable anonymous reporting data to help improve lazygit? (enter/esc)",
+ MergeToolTitle: "Merge tool",
+ MergeToolPrompt: "Are you sure you want to open `git mergetool`?",
IntroPopupMessage: englishIntroPopupMessage,
GitconfigParseErr: `Gogit failed to parse your gitconfig file due to the presence of unquoted '\' characters. Removing these should fix the issue.`,
LcEditFile: `edit file`,