Windows Terminal でコマンドパレットをショートカットキーで出すようにする方法

結論

設定ファイル*1の、actions というディレクティブ内*2に、起動するためのキー割り当てを記載します。

具体例

例えば、ctrl+shift+p で起動する場合には、設定ファイル以下のように書きます(追記します)。

// This file was initially generated by Windows Terminal 1.4.3243.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.

(中略)

    // Add custom actions and keybindings to this array.
    // To unbind a key combination from your defaults.json, set the command to "unbound".
    // To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
    "actions":
    [
        (中略)

        { "command": "commandPalette", "keys": "ctrl+shift+p" }
    ]
}

補足

公式ドキュメント や一部の解説記事を見ても、「{ "command": "commandPalette", "keys": "ctrl+shift+p" } という内容を設定ファイルに追加しろ」と書いてあるだけなので混乱しました。

コマンドパレットを起動した状態の画面

gyazo.com

*1:Windows Terminal のメニューから「設定」を選んで編集できる settings.json

*2:JSON的には「キー」

Powered by はてなブログ