Windows Terminalの私の設定

Windows Terminal のインストール

Windows Terminal User Documentation を見ると Windows Terminal は Microsoft Store からインストール可能です。 私は Releases · microsoft/terminal の Assets からインストーラをダウンロードしてインストールしています。

設定の変更について

2021-07-02 追記

設定についてのドキュメントは Windows Terminal Startup Settings | Microsoft Docs に移動されていました。 

しばらく前のバージョンから Windows Terminal に GUI の設定画面が追加されています。

ウィンドウ上部のタブ追加の+ボタンの右のvボタンでメニューを開いて「設定」をクリックすれば開けます(ショートカットの Ctrl + , キーでも良いです)。

しかし、細かいところは結局 JSON ファイルで編集します。これは設定画面左下の「JSONファイルを開く」を押してお好みのエディターで編集して保存し、エディターを閉じた後 Windows Terminal の設定を閉じます。

以下は元の記述です。

Editing Windows Terminal JSON Settings に説明があります。

私の設定

私の settings.json は以下のようにしています。

2021-07-04 追記: ファイルの構成は Windows Terminal のバージョンで変わる可能性が高いので丸ごとコピーはせず下記の差分を適用していくほうが良いと思います。

// This file was initially generated by Windows Terminal 0.11.1333.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.

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",

    // You can add more global application settings here.
    // To learn more about global settings, visit https://aka.ms/terminal-global-settings
    "initialCols": 162,
    "initialRows": 44,
    "initialPosition": "0,0",

    // If enabled, selections are automatically copied to your clipboard.
    "copyOnSelect": false,

    // If enabled, formatted data is also copied to your clipboard
    "copyFormatting": false,

    // A profile specifies a command to execute paired with information about how it should look and feel.
    // Each one of them will appear in the 'New Tab' dropdown,
    //   and can be invoked from the commandline with `wt.exe -p xxx`
    // To learn more about profiles, visit https://aka.ms/terminal-profile-settings
    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
            "fontFace": "Cica",
            "fontSize": 14,
            "cursorColor": "#FFFFFF",
            "cursorShape": "filledBox",
            "colorScheme": "Tango Dark"
        },
        "list":
        [
            {
                // Make changes here to the powershell.exe profile.
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false
            },
            {
                // Make changes here to the cmd.exe profile.
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "コマンド プロンプト",
                "commandline": "cmd.exe",
                "hidden": false
            },
            {
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore"
            },
            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            }
        ]
    },

    // Add custom color schemes to this array.
    // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
    "schemes": [
        // A profile can override the following color scheme values:
        //   - "foreground"
        //   - "background"
        //   - "cursorColor"
        {
            "name": "Tango Dark",
            "foreground": "#D3D7CF",
            "background": "#000000",
            "cursorColor": "#FFFFFF",
            "black": "#000000",
            "red": "#CC0000",
            "green": "#4E9A06",
            "yellow": "#C4A000",
            "blue": "#3465A4",
            "purple": "#75507B",
            "cyan": "#06989A",
            "white": "#D3D7CF",
            "brightBlack": "#555753",
            "brightRed": "#EF2929",
            "brightGreen": "#8AE234",
            "brightYellow": "#FCE94F",
            "brightBlue": "#729FCF",
            "brightPurple": "#AD7FA8",
            "brightCyan": "#34E2E2",
            "brightWhite": "#EEEEEC"
        }
    ],

    // 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":
    [
        // 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" }
    ]
}

settings.json を消して生成された内容からの差分は以下の通りです。

--- settings.json.default	2020-05-16 21:40:42.105955700 +0900
+++ settings.json	2020-05-16 22:02:57.343686100 +0900
@@ -8,10 +8,13 @@
 {
     "$schema": "https://aka.ms/terminal-profiles-schema",
 
-    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
+    "defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
 
     // You can add more global application settings here.
     // To learn more about global settings, visit https://aka.ms/terminal-global-settings
+    "initialCols": 162,
+    "initialRows": 44,
+    "initialPosition": "0,0",
 
     // If enabled, selections are automatically copied to your clipboard.
     "copyOnSelect": false,
@@ -28,6 +31,11 @@
         "defaults":
         {
             // Put settings here that you want to apply to all profiles.
+            "fontFace": "Cica",
+            "fontSize": 14,
+            "cursorColor": "#FFFFFF",
+            "cursorShape": "filledBox",
+            "colorScheme": "Tango Dark"
         },
         "list":
         [
@@ -68,19 +76,40 @@
 
     // Add custom color schemes to this array.
     // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
-    "schemes": [],
+    "schemes": [
+        // A profile can override the following color scheme values:
+        //   - "foreground"
+        //   - "background"
+        //   - "cursorColor"
+        {
+            "name": "Tango Dark",
+            "foreground": "#D3D7CF",
+            "background": "#000000",
+            "cursorColor": "#FFFFFF",
+            "black": "#000000",
+            "red": "#CC0000",
+            "green": "#4E9A06",
+            "yellow": "#C4A000",
+            "blue": "#3465A4",
+            "purple": "#75507B",
+            "cyan": "#06989A",
+            "white": "#D3D7CF",
+            "brightBlack": "#555753",
+            "brightRed": "#EF2929",
+            "brightGreen": "#8AE234",
+            "brightYellow": "#FCE94F",
+            "brightBlue": "#729FCF",
+            "brightPurple": "#AD7FA8",
+            "brightCyan": "#34E2E2",
+            "brightWhite": "#EEEEEC"
+        }
+    ],
 
     // 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" },
 

2021-07-04 追記: 起動時のカレントディレクトリをWSLのホームディレクトリにする

参考: Windows Terminal Troubleshooting | Microsoft DocsSet your WSL distribution to start in the home ~ directory when launched

settings.json の profiles の list 内の WSL のオブジェクトの startingDirectory キーに //wsl$/【WSLのディストリビューション名】/home/【WSLのユーザ名】 といった値を設定します。 Ubuntu と Ubuntu-20.04 の例を示します。

            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "name": "Ubuntu",
                "startingDirectory": "//wsl$/Ubuntu/home/hnakamur",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
                "hidden": false,
                "name": "Ubuntu-20.04",
                "source": "Windows.Terminal.Wsl",
                "startingDirectory": "//wsl$/Ubuntu-20.04/home/hnakamur"
            }