mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
add menu keybindings for various things
This commit is contained in:
@ -103,24 +103,28 @@ func (self *BasicCommitsController) copyCommitAttribute(commit *models.Commit) e
|
||||
OnPress: func() error {
|
||||
return self.copyCommitSHAToClipboard(commit)
|
||||
},
|
||||
Key: 's',
|
||||
},
|
||||
{
|
||||
DisplayString: self.c.Tr.LcCommitURL,
|
||||
OnPress: func() error {
|
||||
return self.copyCommitURLToClipboard(commit)
|
||||
},
|
||||
Key: 'u',
|
||||
},
|
||||
{
|
||||
DisplayString: self.c.Tr.LcCommitDiff,
|
||||
OnPress: func() error {
|
||||
return self.copyCommitDiffToClipboard(commit)
|
||||
},
|
||||
Key: 'd',
|
||||
},
|
||||
{
|
||||
DisplayString: self.c.Tr.LcCommitMessage,
|
||||
OnPress: func() error {
|
||||
return self.copyCommitMessageToClipboard(commit)
|
||||
},
|
||||
Key: 'm',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
@ -76,6 +76,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
||||
|
||||
return self.afterMark(selectCurrentAfter, waitToReselect)
|
||||
},
|
||||
Key: 'b',
|
||||
},
|
||||
{
|
||||
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.OldTerm()),
|
||||
@ -87,6 +88,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
||||
|
||||
return self.afterMark(selectCurrentAfter, waitToReselect)
|
||||
},
|
||||
Key: 'g',
|
||||
},
|
||||
{
|
||||
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.Skip, commit.ShortSha()),
|
||||
@ -98,12 +100,14 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
||||
|
||||
return self.afterMark(selectCurrentAfter, waitToReselect)
|
||||
},
|
||||
Key: 's',
|
||||
},
|
||||
{
|
||||
DisplayString: self.c.Tr.Bisect.ResetOption,
|
||||
OnPress: func() error {
|
||||
return self.helpers.Bisect.Reset()
|
||||
},
|
||||
Key: 'r',
|
||||
},
|
||||
}
|
||||
|
||||
@ -131,6 +135,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
|
||||
|
||||
return self.helpers.Bisect.PostBisectCommandRefresh()
|
||||
},
|
||||
Key: 'b',
|
||||
},
|
||||
{
|
||||
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.OldTerm()),
|
||||
@ -146,6 +151,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
|
||||
|
||||
return self.helpers.Bisect.PostBisectCommandRefresh()
|
||||
},
|
||||
Key: 'g',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
@ -562,6 +562,7 @@ func (self *FilesController) createStashMenu() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.StashAllChanges)
|
||||
return self.handleStashSave(self.git.Stash.Save)
|
||||
},
|
||||
Key: 's',
|
||||
},
|
||||
{
|
||||
DisplayString: self.c.Tr.LcStashStagedChanges,
|
||||
@ -569,6 +570,7 @@ func (self *FilesController) createStashMenu() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.StashStagedChanges)
|
||||
return self.handleStashSave(self.git.Stash.SaveStagedChanges)
|
||||
},
|
||||
Key: 'S',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
@ -51,6 +51,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
|
||||
}
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 'd',
|
||||
},
|
||||
}
|
||||
|
||||
@ -65,6 +66,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 'u',
|
||||
})
|
||||
}
|
||||
} else {
|
||||
@ -93,6 +95,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
|
||||
}
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 'd',
|
||||
},
|
||||
}
|
||||
|
||||
@ -107,6 +110,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 'u',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -72,18 +72,22 @@ func (self *GitFlowController) handleCreateGitFlowMenu(branch *models.Branch) er
|
||||
{
|
||||
DisplayString: "start feature",
|
||||
OnPress: startHandler("feature"),
|
||||
Key: 'f',
|
||||
},
|
||||
{
|
||||
DisplayString: "start hotfix",
|
||||
OnPress: startHandler("hotfix"),
|
||||
Key: 'h',
|
||||
},
|
||||
{
|
||||
DisplayString: "start bugfix",
|
||||
OnPress: startHandler("bugfix"),
|
||||
Key: 'b',
|
||||
},
|
||||
{
|
||||
DisplayString: "start release",
|
||||
OnPress: startHandler("release"),
|
||||
Key: 'r',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
@ -46,18 +46,29 @@ const (
|
||||
)
|
||||
|
||||
func (self *MergeAndRebaseHelper) CreateRebaseOptionsMenu() error {
|
||||
options := []string{REBASE_OPTION_CONTINUE, REBASE_OPTION_ABORT}
|
||||
|
||||
if self.git.Status.WorkingTreeState() == enums.REBASE_MODE_REBASING {
|
||||
options = append(options, REBASE_OPTION_SKIP)
|
||||
type optionAndKey struct {
|
||||
option string
|
||||
key types.Key
|
||||
}
|
||||
|
||||
menuItems := slices.Map(options, func(option string) *types.MenuItem {
|
||||
options := []optionAndKey{
|
||||
{option: REBASE_OPTION_CONTINUE, key: 'c'},
|
||||
{option: REBASE_OPTION_ABORT, key: 'a'},
|
||||
}
|
||||
|
||||
if self.git.Status.WorkingTreeState() == enums.REBASE_MODE_REBASING {
|
||||
options = append(options, optionAndKey{
|
||||
option: REBASE_OPTION_SKIP, key: 's',
|
||||
})
|
||||
}
|
||||
|
||||
menuItems := slices.Map(options, func(row optionAndKey) *types.MenuItem {
|
||||
return &types.MenuItem{
|
||||
DisplayString: option,
|
||||
DisplayString: row.option,
|
||||
OnPress: func() error {
|
||||
return self.genericMergeCommand(option)
|
||||
return self.genericMergeCommand(row.option)
|
||||
},
|
||||
Key: row.key,
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -134,17 +134,27 @@ func (self *RefsHelper) ResetToRef(ref string, strength string, envVars []string
|
||||
}
|
||||
|
||||
func (self *RefsHelper) CreateGitResetMenu(ref string) error {
|
||||
strengths := []string{"soft", "mixed", "hard"}
|
||||
menuItems := slices.Map(strengths, func(strength string) *types.MenuItem {
|
||||
type strengthWithKey struct {
|
||||
strength string
|
||||
key types.Key
|
||||
}
|
||||
strengths := []strengthWithKey{
|
||||
{strength: "soft", key: 's'},
|
||||
{strength: "mixed", key: 'm'},
|
||||
{strength: "hard", key: 'h'},
|
||||
}
|
||||
|
||||
menuItems := slices.Map(strengths, func(row strengthWithKey) *types.MenuItem {
|
||||
return &types.MenuItem{
|
||||
DisplayStrings: []string{
|
||||
fmt.Sprintf("%s reset", strength),
|
||||
style.FgRed.Sprintf("reset --%s %s", strength, ref),
|
||||
fmt.Sprintf("%s reset", row.strength),
|
||||
style.FgRed.Sprintf("reset --%s %s", row.strength, ref),
|
||||
},
|
||||
OnPress: func() error {
|
||||
self.c.LogAction("Reset")
|
||||
return self.ResetToRef(ref, strength, []string{})
|
||||
return self.ResetToRef(ref, row.strength, []string{})
|
||||
},
|
||||
Key: row.key,
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -158,6 +158,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}})
|
||||
})
|
||||
},
|
||||
Key: 'i',
|
||||
},
|
||||
{
|
||||
DisplayStrings: []string{self.c.Tr.LcBulkUpdateSubmodules, style.FgYellow.Sprint(self.git.Submodule.BulkUpdateCmdObj().ToString())},
|
||||
@ -171,6 +172,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}})
|
||||
})
|
||||
},
|
||||
Key: 'u',
|
||||
},
|
||||
{
|
||||
DisplayStrings: []string{self.c.Tr.LcBulkDeinitSubmodules, style.FgRed.Sprint(self.git.Submodule.BulkDeinitCmdObj().ToString())},
|
||||
@ -184,6 +186,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}})
|
||||
})
|
||||
},
|
||||
Key: 'd',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
@ -31,6 +31,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 'D',
|
||||
},
|
||||
{
|
||||
DisplayStrings: []string{
|
||||
@ -45,6 +46,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 'u',
|
||||
},
|
||||
{
|
||||
DisplayStrings: []string{
|
||||
@ -59,6 +61,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 'c',
|
||||
},
|
||||
{
|
||||
DisplayStrings: []string{
|
||||
@ -73,6 +76,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 's',
|
||||
},
|
||||
{
|
||||
DisplayStrings: []string{
|
||||
@ -87,6 +91,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 'm',
|
||||
},
|
||||
{
|
||||
DisplayStrings: []string{
|
||||
@ -101,6 +106,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 'h',
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -17,14 +17,17 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
|
||||
{
|
||||
DisplayString: "reset patch",
|
||||
OnPress: gui.handleResetPatch,
|
||||
Key: 'c',
|
||||
},
|
||||
{
|
||||
DisplayString: "apply patch",
|
||||
OnPress: func() error { return gui.handleApplyPatch(false) },
|
||||
Key: 'a',
|
||||
},
|
||||
{
|
||||
DisplayString: "apply patch in reverse",
|
||||
OnPress: func() error { return gui.handleApplyPatch(true) },
|
||||
Key: 'r',
|
||||
},
|
||||
}
|
||||
|
||||
@ -33,14 +36,17 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
|
||||
{
|
||||
DisplayString: fmt.Sprintf("remove patch from original commit (%s)", gui.git.Patch.PatchManager.To),
|
||||
OnPress: gui.handleDeletePatchFromCommit,
|
||||
Key: 'd',
|
||||
},
|
||||
{
|
||||
DisplayString: "move patch out into index",
|
||||
OnPress: gui.handleMovePatchIntoWorkingTree,
|
||||
Key: 'i',
|
||||
},
|
||||
{
|
||||
DisplayString: "move patch into new commit",
|
||||
OnPress: gui.handlePullPatchIntoNewCommit,
|
||||
Key: 'n',
|
||||
},
|
||||
}...)
|
||||
|
||||
@ -55,6 +61,7 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
|
||||
{
|
||||
DisplayString: fmt.Sprintf("move patch to selected commit (%s)", selectedCommit.Sha),
|
||||
OnPress: gui.handleMovePatchToSelectedCommit,
|
||||
Key: 'm',
|
||||
},
|
||||
}, menuItems[1:]...,
|
||||
)...,
|
||||
|
Reference in New Issue
Block a user