TransWikia.com

assign keybinding to windows terminal profile

Super User Asked on January 3, 2022

I would like to assign to one of the new windows terminal profiles a keybinding, as in the following ("keys": "alt+shift+d"):

        {
            // Connects to a remote machine using SSH
            "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "name":  "SSH My Local Server",
            "tabTitle": "Local Server",
            "commandline": "ssh [email protected]",
            "keys": "alt+shift+d"
        },

what is the way to do this?

One Answer

There is no keys property in Profile settings in Windows Terminal. However, you can create custom key bindings (keyboard shortcuts) inside Windows Terminal that give you control of how you interact with the terminal using your keyboard.

The altshift+d shortcut is (by default) dedicated to open a new pane - as you can see in the corresponding part of settings.json:

// Add custom keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about keybindings, visit https://aka.ms/terminal-keybindings
"keybindings":
[
    // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
    // These two lines additionally bind them to Ctrl+C and Ctrl+V.
    // To learn more about selection, visit https://aka.ms/terminal-selection
    { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
    { "command": "paste", "keys": "ctrl+v" },

    // Press Ctrl+Shift+F to open the search box
    { "command": "find", "keys": "ctrl+shift+f" },

    // Press Alt+Shift+D to open a new pane.
    // - "split": "auto" makes this pane open in the direction that provides the most surface area.
    // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
    // To learn more about panes, visit https://aka.ms/terminal-panes
    { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
]

You can delete this keyboard shortcut here and add appropriate part from the following default binding schema, for instance (if your "SSH My Local Server" is the 3rd entry in the profile list)

{ "command": { "action": "newTab", "index": 2 }, "keys": "alt+shift+d" },

Answered by JosefZ on January 3, 2022

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP