- コンソールで使用するフォントについて
- ColorTool使い方
以下のsrc/tools/ColorTool以下にソースがあるので、VS2017以降でビルドします。
Microsoft/terminal
https://github.com/microsoft/terminal
VisualStudio2017未満であれば以下からexeをダウンロードしたほうがいいです。
https://github.com/microsoft/terminal/releases/tag/1904.29002
# スキーマの一覧 (現在のコマンドプロンプトのデフォルトはcampbell.ini)
> ColorTool.exe -s
campbell-legacy.ini
campbell.ini
cmd-legacy.ini
deuteranopia.itermcolors
OneHalfDark.itermcolors
OneHalfLight.itermcolors
solarized_dark.itermcolors
solarized_light.itermcolors
# スキーマを設定 ( ex. OneHalfDark)
> ColorTool.exe -b OneHalfDark.itermcolors
# 現在のカラー設定をiniファイルに出力する
> ColorTool.exe -o test.ini
# 出力したiniファイルを読み込んでデフォルトに設定する
> ColorTool.exe -d test.ini
# 出力したiniファイルを読み込んでカレントに設定する
# コマンド実行後、プロパティを開いてOKを押さないと設定されない
> ColorTool.exe test.ini
コマンドプロンプト、PowerShell、WSLのカラースキーマ設定
この3つのコンソールの色設定について、デフォルトカラーは共通で、各コンソールが個別に変更している色をそれぞれレジストリで保存しているような感じです。
デフォルトがHKEY_CURRENT_USER\Console
直下のColorTable00~15の値がそれになります。その下にPowerShell、Cmd、WSLのキーがあってPowerShellなどは色の差分をここで保存しているんじゃないかと。
筆者の場合は、CmdとWSLを使うので、WSL向けをデフォルトに後述するUbuntuColorを設定し、Cmd向けはカレントツールにOneHalfDarkを設定してみる。
- UbuntuColor
以下サイトの設定値を参考に設定
https://winaero.com/blog/bash-look-ubuntu-terminal-windows-10/
# ubuntu_color.ini
[table]
DARK_BLACK = 48,10,36
DARK_BLUE = 52,101,164
DARK_GREEN = 78,154,6
DARK_CYAN = 6,152,154
DARK_RED = 204,0,0
DARK_MAGENTA = 117,80,123
DARK_YELLOW = 196,160,0
DARK_WHITE = 211,215,207
BRIGHT_BLACK = 85,87,83
BRIGHT_BLUE = 114,159,207
BRIGHT_GREEN = 138,226,52
BRIGHT_CYAN = 52,226,226
BRIGHT_RED = 239,41,41
BRIGHT_MAGENTA = 173,127,168
BRIGHT_YELLOW = 252,233,79
BRIGHT_WHITE = 238,238,238
[screen]
FOREGROUND = DARK_WHITE
BACKGROUND = DARK_BLACK
[popup]
FOREGROUND = DARK_MAGENTA
BACKGROUND = BRIGHT_WHITE
コマンドプロンプトを起動して以下を実行する
> ColorTool.exe -d ubuntu_color.ini
WSL.exeを起動して色を確認してみると、Ubuntuのターミナルな感じになってなかなかGood
dircolorsの変更
777パーミッションのディレクトリの色が気に入らないので変更したい。
参考サイト
https://www.kwbtblog.com/entry/2019/04/27/023411
Ubuntu内のdircolorsファイルで別の色を定義して変更する。まずWSLでUbuntuにログインして.dircolorsの設定ファイルをユーザディレクトリに作成する。
> cd ~
> dircolors -p > ~/.dircolors
> cat .dircolors
:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
#NORMAL 00 # no color code at all
#FILE 00 # regular file: use no color at all
RESET 0 # reset to "normal" color
DIR 01;34 # directory
LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 00 # regular file with more than one link
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ...
MISSING 00 # ... and the files they point to
SETUID 37;41 # file that is setuid (u+s)
SETGID 30;43 # file that is setgid (g+s)
CAPABILITY 30;41 # file with capability
:
参考サイトに真似て設定
OTHER_WRITABLE 01;32
コンソールを起動して確認
コンテキストメニューからWSLコマンドを実行できるようにする
Git For Windowsをインストールすると、"Git Bash Here"というコンテキストメニューが表示される。これと同等のことをWSLでもできるようにする。
コンテキストメニューに追加するレジストリ設定
Windows Registry Editor Version 5.00
`HKEY_CURRENT_USER\SOFTWARE\Classes`以下にあるDirecotry、Drive、DesktopBackgroundにそれぞれ`wsl.exe`を実行する設定を追加します。コンテキストメニューのラベルは"Open Bash here"として、Ubuntuのアイコンを設定しています。アイコンファイルの場所は`%USERPROFILE%/ubuntu.ico`です。
[HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\shell\openbashhere]
@="Open Bash here"
"Icon"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,75,00,62,00,75,00,6e,00,74,00,75,00,2e,00,69,00,63,00,\
6f,00,00,00
[HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\shell\openbashhere\command]
@="wsl.exe"
[HKEY_CURRENT_USER\SOFTWARE\Classes\Drive\shell\openbashhere]
@="Open Bash here"
"Icon"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,75,00,62,00,75,00,6e,00,74,00,75,00,2e,00,69,00,63,00,\
6f,00,00,00
[HKEY_CURRENT_USER\SOFTWARE\Classes\Drive\shell\openbashhere\command]
@="wsl.exe"
[HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell\openbashhere]
@="Open Bash here"
"Icon"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,75,00,62,00,75,00,6e,00,74,00,75,00,2e,00,69,00,63,00,\
6f,00,00,00
[HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell\openbashhere\command]
@="wsl.exe"
[HKEY_CURRENT_USER\SOFTWARE\Classes\DesktopBackground\shell\openbashhere]
@="Open Bash here"
"Icon"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
00,45,00,25,00,5c,00,75,00,62,00,75,00,6e,00,74,00,75,00,2e,00,69,00,63,00,\
6f,00,00,00
[HKEY_CURRENT_USER\SOFTWARE\Classes\DesktopBackground\shell\openbashhere\command]
@="wsl.exe"
コンテキストメニュー解除用レジストリファイル
追加したキーを削除するレジストリになる。
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\shell\openbashhere]
[-HKEY_CURRENT_USER\SOFTWARE\Classes\Drive\shell\openbashhere]
[-HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell\openbashhere]
[-HKEY_CURRENT_USER\SOFTWARE\Classes\DesktopBackground\shell\openbashhere]