Windows Treminal(WT)はMicrosoftが開発したターミナル。
見た目がきれいでショートカットのカスタマイズができてPowerShellもWSLも動かせてうれしい。
私のWTの見た目とsettings.json
を公開する。
ちなみにこのシェルはfish、テーマはoh-my-fish/theme-agnosterです。
Windows ターミナルとは
Windows ターミナルは、コマンド プロンプト、PowerShell、Linux 用 Windows サブシステム (WSL) などのコマンドライン ツールとシェルのユーザー向けの最新のターミナル アプリケーションです。 主な機能には、複数のタブ、ペイン、Unicode および UTF-8 文字のサポート、GPU で高速化されたテキスト レンダリング エンジン、独自のテーマを作成したり、テキスト、色、背景、およびショートカットをカスタマイズしたりする機能があります。
https://docs.microsoft.com/ja-jp/windows/terminal/より引用。アクセス日は2020年12月23日。
公式ドキュメントhttps://docs.microsoft.com/ja-jp/windows/terminal/はよく書かれているのでわからないことがあったら見ましょう。
settings.json
CTRL + ,を押すとエディタで設定ファイルsettings.json
が開かれる。
GUIDはユニークでもしかしたら公開したら困るかもしれないので一応*
で置換しておきます。
// 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. // 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": "{************************************}", // You can add more global application settings here. // To learn more about global settings, visit https://aka.ms/terminal-global-settings // 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 "initialRows": 20, "initialCols": 80, "profiles": { "defaults": { // Put settings here that you want to apply to all profiles. "cursorShape": "filledBox", "useAcrylic": true, "acrylicOpacity": 0.8, "colorScheme": "One Half Dark", "fontFace": "Cascadia Mono PL" }, "list": [ { "guid": "{************************************}", "hidden": false, "name": "Ubuntu", "source": "Windows.Terminal.Wsl", "background": "#250e20", "startingDirectory": "//wsl$/Ubuntu/home/hotaru" }, { "guid": "{************************************}", "hidden": false, "name": "PowerShell", "source": "Windows.Terminal.PowershellCore", "background": "#120e25" }, { // Make changes here to the powershell.exe profile. "guid": "{************************************}", "name": "Windows PowerShell", "commandline": "powershell.exe", "hidden": true }, { // Make changes here to the cmd.exe profile. "guid": "{************************************}", "name": "Command Prompt", "commandline": "cmd.exe", "hidden": true }, { "guid": "{************************************}", "hidden": true, "name": "PowerShell (dotnet global)", "source": "Windows.Terminal.PowershellCore" }, { "guid": "{************************************}", "hidden": true, "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": [], // 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": [ // 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" } ] }
デフォルトをUbuntuに
WSLをメインで使うのでデフォルトのプロファイルをWSLに変更した。
そのためdefaultProfile
をUbuntuのguidに変更した。
"defaultProfile": "{************************************}", // Ubuntuのguid
Ubuntu・PowerShell以外を隠す
Ubuntu・PowerShell以外のプロファイルは使わないので隠した。
そのためにhidden
をtrue
に変える。
{ // Make changes here to the cmd.exe profile. "guid": "{************************************}", "name": "Command Prompt", "commandline": "cmd.exe", "hidden": true },
Ubuntuの開始ディレクトリをUbuntuのホームディレクトリに変更
デフォルトではUbuntuの開始ディレクトリはWindowsのホームディレクトリ。 開始ディレクトリはUbuntuのホームディレクトリであってほしいので変更。
"startingDirectory": "//wsl$/Ubuntu/home/hotaru"
UbuntuのホームディレクトリからWindowsのホームディレクトリに早く移動したいときのためにシンボリックリンクln -s /mnt/c/Users/hotaru/ winhome
を作った。
ウィンドウのサイズ
デフォルトでは大きすぎると感じたので20×80に変更した。
"initialRows": 20, "initialCols": 80,
ウィンドウの見た目
透明度0.5では白背景のときに灰色文字が見ずらいため0.8にした。
"defaults": { // Put settings here that you want to apply to all profiles. "cursorShape": "filledBox", "useAcrylic": true, "acrylicOpacity": 0.8, "colorScheme": "One Half Dark", "fontFace": "Cascadia Mono PL" },
Ubuntuの背景色を暗い紫色💜、PowerShellの背景色を暗い青色💙にした。 見分けがつくとうれしい。
"background": "#250e20", ... "background": "#120e25"
ショートカット
エクスプローラーで開いているディレクトリをWTで開く
エクスプローラーのアドレス欄にwt -d .
と入力する。
もちろんターミナルで打っても良い。
指定したプロファイルでWT
wt -p Ubuntu
などと入力する。
open hoge.jpgとかで画像開けたりするやつ
WSL、これしたらopen hoge.jpg とかで画像開けたりhtml開けたりしてかなりQoLが上がった pic.twitter.com/3jaa3riCyq
— keymoon (@kymn_) December 20, 2020