Is there any submap feature in lazygit? #5052
|
Hello, I've started using lazygit for 2 months. I don't know, but I wanted to ask, is there any submap feature in lazygit? I want to add my custom git aliases as a submap. If not, I would love to have this feature in lazygit. |
Replies: 3 comments 7 replies
|
What is a submap? Can you explain in more detail what you want to do? |
|
@stefanhaller A submap basically like a menu option which contains set of specific assigned keys which allows us to use a single key combination to perform multiple set of option. Here is a short example from hyprland: $mainMod=SUPER
bind=$mainMod, E ,submap,files
submap=files
# shortcuts for impotant folders
bind = , D, exec, hyprctl dispatch submap reset; $fileManager ~/Downloads/
bind = , M, exec, hyprctl dispatch submap reset; $fileManager ~/Music/
bind = , V, exec, hyprctl dispatch submap reset; $fileManager ~/Videos/
bind = , P, exec, hyprctl dispatch submap reset; $fileManager ~/Pictures/
bind = , W, exec, hyprctl dispatch submap reset; $fileManager ~/Documents/
bind = , C, exec, hyprctl dispatch submap reset; $fileManager ~/code/
bind= , escape , submap, reset
submap=resetHere we press This allows me to add more keymaps in a single key combination menu. |
|
I'm keeping this sample code for future visitors for answer keybinding:
universal:
pushFiles: <disabled>
pullFiles: <disabled>
customCommands:
- key: "C"
command: "git cz"
description: "commit with commitizen"
context: "files"
loadingText: "opening commitizen commit tool"
output: terminal
- key: "P"
description: "Push"
commandMenu:
- key: p
command: "git push --force-with-lease"
description: "Push"
loadingText: "Pushing"
- key: a
command: "git remote | xargs -L1 git push --all"
description: "Push (Remotes)"
loadingText: "Pushing to all remotes"
- key: A
command: "git remote | xargs -L1 git push --all --force"
description: "Push (Remotes + Force)"
loadingText: "Pushing to all remotes by force"
- key: "p"
description: "Pull"
commandMenu:
- key: p
command: "git pull --no-edit"
description: "Pull"
loadingText: "Pulling"
- key: r
command: "git pull --rebase"
description: "Pull (Rebase)"
loadingText: "Pulling with rebase"
|

We have many examples of this in lazygit, e.g. the rebase menu in the branches panel, the bisect menu in the Commits panel, and many others. We do these case-by-case if we find that a particular command benefits from more finegrained options. Sometimes we add these later on for commands that originally didn't have them; one example is the
dcommand in the branches panel, which initially only showed a confirmation ("Are you sure you want to delete this branch?"), and later we turned it into a menu with more options.For your custom git aliases, it sounds like you want to use custom commands, which also have this feature. See https://github.com/jesseduffield/lazygit/blob/master/docs/Custom_…