lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Keybindings for Custom Command's Prompt menus

Open rtalexk opened this issue 1 year ago • 0 comments

I'm creating a custom command with a menu prompt, similar to the "Reset to [commit hash]" menu.

image

Mine looks like this:

image
Configuration

In summary, what this does is allowing me to edit a file by reusing an existing $EDITOR instance in a Tmux window. Or, I can also choose to edit the file in the current window, or in a new $EDITOR instance (that's handled by the lazygit_edit_cmd script).

customCommands:
  - name: "edit"
    context: "files"
    key: "e"
    prompts:
      - type: "menu"
        title: "Editor instance"
        key: "WinChoise"
        options:
          - value: "reuse"
            description: "Search for a Window with an EDITOR instance"
            key: "r" # <-- This is what I want
          - value: "current"
            description: "Edit the file in the current window"
            key: "c" # <-- This is what I want
          - value: "new"
            description: "Edit the file in a new window"
            key: "n" # <-- This is what I want
    command: "lazygit_edit_cmd -w {{.Form.WinChoise}} {{.SelectedFile.Name}}"
    subprocess: true

Describe the solution you'd like What I would like to have is mapping some keybinding to options in the prompt menu, just as in the Reset menu with m for Mixed, s for Soft and h for Hard reset.

Right now I mostly use the "Reuse" option (that's why it is the first one), and that's my workaround, but it would be cool if that's something that can be configured.

I read the Custom Commands docs and I didn't see any way to set bindings, if I missed that part please let me know.

rtalexk avatar Jun 01 '24 07:06 rtalexk