79218988

Date: 2024-11-23 22:54:15
Score: 1
Natty:
Report link

Thanks to @Alfred Luu's idea of using keybindings.

When you are staging commits in the integrated terminal, it's useful to have copilot suggest the commit message, allow you to make any edits, and then commit- without needing the mouse and returning the focus to the terminal for further commands like git status and git log

To add this functionality:

  1. In VSCode open your keyboard shortcuts to add a new shortcut. You can do this by pressing f1 and then type Preferences: Open Keyboard Shortcuts (JSON). This will open your keybindings.json file where you can save your custom keybinds.

  2. Inside, paste these three new keybindings:

    {
        "key": "ctrl+oem_1",
        "command" : "runCommands",
        "args": {
            "commands": [
                "workbench.view.scm",
                "github.copilot.git.generateCommitMessage",
            ]
        }
    },
    {
        "key" : "ctrl+oem_7",
        "command" : "runCommands",
        "args": {
            "commands": [
                "git.commit",
                "workbench.action.focusActiveEditorGroup",
            ]
        },
        "when": "!terminalFocus"
    },
    {
        "key": "ctrl+oem_7",
        "command": "runCommands",
        "args": {
            "commands": [
                "git.commit",
                "workbench.action.terminal.focus",
            ]
        },
        "when": "terminalFocus"
    }
  1. Replace the "key" with the keyboard shortcut you want for the two behaviours.

    • E.g.: "key": "ctrl+m"
  2. Save keybindings.json

How to use

My defaults are:

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @Alfred
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: SWA