コマンド パレットでは、Windows ターミナル内で実行できるアクションを確認できます。 アクションの定義方法の詳細については、「 アクション」ページを参照してください。
コマンド パレットの呼び出し
Ctrl + Shift + P キーを押すと、コマンド パレットを呼び出すことができます。 これをカスタマイズするには、 commandPalette
コマンドをキー バインドに追加します。
{ "command": "commandPalette", "keys": "ctrl+shift+p" }
コマンド ライン モード
コマンド パレットに wt
コマンドを入力する場合は、テキスト ボックスの >
文字を削除します。 これにより、現在のウィンドウで wt
コマンドが実行されます。
wt
コマンドの詳細については、「コマンド ライン引数」ページを参照してください。
コマンド ライン モードでコマンド パレットを直接呼び出すためのカスタム キー バインドを追加できます。
{ "command": "commandPalette", "launchMode": "commandLine", "keys": "" }
コマンドへのアイコンの追加
必要に応じて、コマンド パレットに表示される settings.json で定義されているコマンドにアイコンを追加できます。 これを行うには、 icon
プロパティをアクションに追加します。 アイコンには、画像へのパス、 Segoe MDL2 アセットのシンボル、または絵文字を含む任意の文字を指定できます。
{ "icon": "C:\\Images\\my-icon.png", "name": "New tab", "command": "newTab", "keys": "ctrl+shift+t" },
{ "icon": "\uE756", "name": "New tab", "command": "newTab", "keys": "ctrl+shift+t" },
{ "icon": "⚡", "name": "New tab", "command": "newTab", "keys": "ctrl+shift+t" }
注
Windows ターミナル 1.24 の時点で、 icon
は settings.json
ファイルに隣接するコンテンツを参照できます。
入れ子になったコマンド
入れ子になったコマンドを使用すると、コマンド パレットの 1 つの項目の下に複数のコマンドをグループ化できます。 次の例では、"フォント サイズの変更..." という 1 つのコマンド パレット項目の下にフォント サイズ変更コマンドをグループ化します。
{
"name": "Change font size...",
"commands": [
{ "command": { "action": "adjustFontSize", "delta": 1 } },
{ "command": { "action": "adjustFontSize", "delta": -1 } },
{ "command": "resetFontSize" },
]
}
Iterable コマンド
Iterable コマンドを使用すると、設定で定義されている他のオブジェクトから生成された複数のコマンドを同時に作成できます。 現時点では、プロファイルと配色に対応する iterable コマンドを作成できます。 実行時に、これらのコマンドは、指定された型のオブジェクトごとに 1 つのコマンドに展開されます。
現在、次のプロパティを反復処理できます。
iterateOn |
プロパティ | プロパティの構文 |
---|---|---|
profiles |
name |
"name": "${profile.name}" |
profiles |
icon |
"icon": "${profile.icon}" |
schemes |
name |
"name": "${scheme.name}" |
Example
プロファイルごとに新しいタブ コマンドを作成します。
{
"iterateOn": "profiles",
"icon": "${profile.icon}",
"name": "${profile.name}",
"command": { "action": "newTab", "profile": "${profile.name}" }
}
上記の例では、次のようになります。
-
"iterateOn": "profiles"
では、プロファイルごとにコマンドが生成されます。 - 実行時に、ターミナルは
${profile.icon}
を各プロファイルのアイコンに置き換え、${profile.name}
を各プロファイルの名前に置き換えます。
3 つのプロファイルがある場合:
"profiles": [
{ "name": "Command Prompt", "icon": null },
{ "name": "PowerShell", "icon": "C:\\path\\to\\icon.png" },
{ "name": "Ubuntu", "icon": null },
]
上記のコマンドは、次の 3 つのコマンドのように動作します。
{
"icon": null,
"name": "Command Prompt",
"command": { "action": "newTab", "profile": "Command Prompt" }
},
{
"icon": "C:\\path\\to\\icon",
"name": "PowerShell",
"command": { "action": "newTab", "profile": "PowerShell" }
},
{
"icon": null,
"name": "Ubuntu",
"command": { "action": "newTab", "profile": "Ubuntu" }
}
入れ子になったコマンドと iterable コマンドを組み合わせることもできます。 たとえば、上の図に示すように、コマンド パレットの 1 つの "新しいタブ" エントリの下に、上の 3 つの "新しいタブ" コマンドを組み合わせることができます。
{
"name": "New tab",
"commands": [
{
"iterateOn": "profiles",
"icon": "${profile.icon}",
"name": "${profile.name}",
"command": { "action": "newTab", "profile": "${profile.name}" }
}
]
}
コマンドを非表示にする
キー バインドリストにコマンドを保持し、コマンド パレットに表示しない場合は、 name
を null
に設定して非表示にすることができます。 次の例では、コマンド パレットから [新しいタブ] アクションを非表示にします。
{ "name": null, "command": "newTab", "keys": "ctrl+shift+t" }
Windows Terminal