Windows 終端機內的窗格Panes in Windows Terminal

窗格能讓您在同一個索引標籤內,以相鄰的方式執行多個命令列應用程式。這可讓您不必頻繁地切換索引標籤,並讓您可以一次看到多個命令提示。Panes give you the ability to run multiple command-line applications next to each other within the same tab. This minimizes the need to switch between tabs and lets you see multiple prompts at once.

建立新窗格Creating a new pane

使用鍵盤Using the keyboard

您可以在 Windows 終端機中建立新的垂直或水平窗格。You can either create a new vertical or horizontal pane in Windows Terminal. 垂直分割會在焦點所在窗格的右側開啟新窗格,水平分割則會在焦點所在窗格的下方開啟新窗格。Splitting vertically will open a new pane to the right of the focused pane and splitting horizontally will open a new pane below the focused pane. 若要為預設設定檔建立新的垂直窗格,您可以輸入 alt+shift+加號To create a new vertical pane of your default profile, you can type alt+shift+plus. 如需預設設定檔的水平窗格,則可以輸入 alt+shift+減號For a horizontal pane of your default profile, you can type alt+shift+-.

Windows 終端機建立窗格 設定:Raspberry UbuntuWindows Terminal create pane Configuration: Raspberry Ubuntu

如果您想要變更這些按鍵繫結,則可以使用 splitPane 動作以及為 profiles.json 檔案的 split 屬性使用 verticalhorizontal 值來建立新的按鍵繫結。If you would like to change these key bindings, you can create new ones using the splitPane action and vertical or horizontal values for the split property in your profiles.json file. 如果您只是想要有最大介面區範圍的窗格,則可以將 split 設定為 autoIf you just want a pane with the maximum amount of surface area, you can set split to auto. 若要深入了解按鍵繫結,請瀏覽按鍵繫結頁面To learn more about key bindings, visit the key bindings page.

{ "command": { "action": "splitPane", "split": "vertical" }, "keys": "alt+shift+plus" },
{ "command": { "action": "splitPane", "split": "horizontal" }, "keys": "alt+shift+-" },
{ "command": { "action": "splitPane", "split": "auto" }, "keys": "alt+shift+|" }

使用下拉式功能表 (預覽)Using the dropdown menu (Preview)

如果您想要透過下拉式功能表開啟新的窗格,可以按住 alt,然後按一下您想要的設定檔。If you'd like to open a new pane through the dropdown menu, you can hold alt and click on your desired profile. 這會將使用中視窗或窗格 auto 分割成所選設定檔的新窗格。This will auto split the active window or pane into a new pane of the selected profile. auto 分割模式會以具有最長邊緣的方向分割來建立窗格。The auto split mode splits in the direction that has the longest edge to create a pane.

Windows 終端機下拉式窗格

重要

這項功能僅適用於 Windows 終端機預覽This feature is only available in Windows Terminal Preview.

在窗格之間切換Switching between panes

終端機可讓您使用鍵盤來瀏覽不同窗格。The terminal allows you to navigate between panes by using the keyboard. 如果您按住 alt 鍵,就可以使用方向鍵在窗格之間移動焦點。If you hold the alt key, you can use your arrow keys to move your focus between panes. 您可以透過窗格周圍的輔色框線來識別焦點所在的窗格。You can identify which pane is in focus by the accent color border surrounding it. 請注意,此輔色會設定在您的 Windows 色彩設定內。Note that this accent color is set in your Windows color settings.

Windows 終端機切換窗格

您可以藉由為 moveFocus 命令新增按鍵繫結,並將 direction 設定為 downleftrightup 來自訂此功能。You can customize this by adding key bindings for the moveFocus command and setting the direction to either down, left, right or up.

{ "command": { "action": "moveFocus", "direction": "down" }, "keys": "alt+down" },
{ "command": { "action": "moveFocus", "direction": "left" }, "keys": "alt+left" },
{ "command": { "action": "moveFocus", "direction": "right" }, "keys": "alt+right" },
{ "command": { "action": "moveFocus", "direction": "up" }, "keys": "alt+up" }

調整窗格大小Resizing a pane

您可以藉由按住 alt+shift 並使用方向鍵調整焦點所在窗格的大小,來調整您窗格的大小。You can adjust the size of your panes by holding alt+shift and using your arrow keys to resize the focused pane.

Windows 終端機建立窗格

若要自訂此按鍵繫結,您可以使用 resizePane 動作並將 direction 設定為 downleftrightup 來新增新的按鍵繫結。To customize this key binding, you can add new ones using the resizePane action and setting the direction to either down, left, right, or up.

{ "command": { "action": "resizePane", "direction": "down" }, "keys": "alt+shift+down" },
{ "command": { "action": "resizePane", "direction": "left" }, "keys": "alt+shift+left" },
{ "command": { "action": "resizePane", "direction": "right" }, "keys": "alt+shift+right" },
{ "command": { "action": "resizePane", "direction": "up" }, "keys": "alt+shift+up" }

關閉窗格Closing a pane

您可以輸入 ctrl+shift+w 來關閉焦點所在窗格。You can close the focused pane by typing ctrl+shift+w. 如果您只有一個窗格,ctrl+shift+w 將會關閉索引標籤。一如往常,關閉最後一個索引標籤就會關閉視窗。If you only have one pane, ctrl+shift+w will close the tab. As always, closing the last tab will close the window.

Windows 終端機關閉窗格

您可以藉由新增使用 closePane 命令的按鍵繫結,來變更會關閉窗格的按鍵。You can change which keys close the pane by adding a key binding that uses the closePane command.

{ "command": "closePane", "keys": "ctrl+shift+w" }

使用按鍵繫結來自訂窗格Customizing panes using key bindings

您可以根據自訂的按鍵繫結,來自訂要在新窗格內開啟的內容。You can customize what opens inside a new pane depending on your custom key bindings.

複製窗格Duplicating a pane

終端機可讓您將焦點所在窗格的設定檔複製到另一個窗格。The terminal allows you to duplicate the focused pane's profile into another pane.

Windows 終端機複製窗格

新增 splitMode 屬性並以 duplicate 作為 splitPane 按鍵繫結的值,即可完成這項作業。This can be done by adding the splitMode property with duplicate as the value to a splitPane key binding.

{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }

新的終端機引數New terminal arguments

Windows 終端機內的新終端機引數New Terminal Arguments in the Windows Terminal

使用按鍵繫結開啟新的窗格或索引標籤時,您可以藉由包含設定檔的名稱、guid 或索引來指定所要使用的設定檔。When opening a new pane or tab with a key binding, you can specify which profile is used by including the profile's name, guid, or index. 如果未指定任何項目,則會使用預設設定檔。If none are specified, the default profile is used. 您可以藉由將 profileindex 新增為 splitPanenewTab 按鍵繫結的引數來完成此作業。This can be done by adding profile or index as an argument to a splitPane or newTab key binding. 請注意,索引編制會從 0 開始。Note that indexing starts at 0.

{ "command": { "action": "splitPane", "split": "vertical", "profile": "profile1" }, "keys": "ctrl+a" },
{ "command": { "action": "splitPane", "split": "vertical", "profile": "{00000000-0000-0000-0000-000000000000}" }, "keys": "ctrl+b" },
{ "command": { "action": "newTab", "index": 0 }, "keys": "ctrl+c" }

此外,您也可以覆寫設定檔的某些層面,例如設定檔的命令列可執行檔、起始目錄或索引標籤標題。Additionally, you can override certain aspects of the profile such as the profile's command line executable, starting directory, or tab title. 這可以藉由將 commandlinestartingDirectory 和/或 tabTitle 新增至 splitPanenewTab 按鍵繫結來完成。This can be accomplished by adding commandline, startingDirectory, and/or tabTitle to a splitPane or newTab key binding.

{ "command": { "action": "splitPane", "split": "auto", "profile": "profile1", "commandline": "foo.exe" }, "keys": "ctrl+a" },
{ "command": { "action": "newTab", "profile": "{00000000-0000-0000-0000-000000000000}", "startingDirectory": "C:\\foo" }, "keys": "ctrl+b" },
{ "command": { "action": "newTab", "index": 0, "tabTitle": "bar", "startingDirectory": "C:\\foo", "commandline": "foo.exe" }, "keys": "ctrl+c" }