Welcome to new things

[Technical] [Electronic work] [Gadget] [Game] memo writing

Fix WSL's Windows folder colors that are hard to see.

WSL (Windows Subsystem for Linux) files and folders are closed within WSL and cannot be accessed from outside WSL, such as Explorer.

So I use a symbolic link to refer to a Windows folder as a location that can be accessed from both WSL and Windows.

It is convenient and I use it often, but there is a problem: when I look at the list of files in "ls", the color of the Windows folders is very difficult to see, with blue text on a green background.

Fix WSL's Windows folder color is hard to see.

Reason

Windows folders and files will have write permission for other users when viewed from the WSL.

And this is because the default color setting for "ls" is blue text on a green background for folders with write permission for other users.

So, we will change the "ls" color setting to handle this.

procedure

flow

  • The color setting of "ls" is done by the environment variable "LS_COLORS".

    • You can edit "LS_COLORS" directly, but here we will use the command "dircolors" to make the configuration easier.
  • The "dircolors" command is

    • Outputs default color settings in an easy-to-understand format
    • It reads the color settings file in the same format as the output and sets the "LS_COLORS" variable

The process is as follows

  1. Output settings to a file once with "dircolors".
  2. Edit the file to get the color you want.
  3. Load the file edited by "dircolors" from the shell startup script and set "LS_COLORS".

Output LS color setting file

dircolors -p > ~/.dircolors

Edit LS color setting file

The folder with write permission for OTHER USER is "OTHER_WRITEBLE" and its value is "34;42" = "text blue;background green".

...
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
...

Here I used "01;32" = "bold; text green".

...
OTHER_WRITABLE 01;32 # dir that is other-writable (o+w) and not sticky
...

How to set colors

Color setting methods are described in the comments of the output configuration file. For each type of file, directory, etc. (OTHER_WRITEBLE, etc.), "Attribute codes", "Text color codes", and "Background color codes" can be set, and the values are connected by ";". (It is not necessary to set all three.)

# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 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

LS_COLORS setting

The code to set LS_COLORS is output with dircolors -b [configuration file path]., so add the following to ".bashrc" or similar file.

eval $(dircolors -b ~/.dircolors)

That is all. When you re-launch the shell, the Windows folder is in green text.

Fix WSL's Windows folder color is hard to see.

bonus

▼ Addendum 06/26/2019 (from here)

Windows Terminal was up on the Microsoft Store, so I installed it.

Fix WSL's Windows folder color is hard to see.

I can use the color theme. We can now wait for the official release with peace of mind.

Fix WSL's Windows folder color is hard to see.

The settings are based on the following article. Note that the theme name may require a space.

https://www.howtogeek.com/426346/how-to-customize-the-new-windows-terminal-app/

▲Addendum (so far)

A Microsoft tool called "ColorTool" allows you to change the color theme of WSL, Command Prompt, and PowerShell.

github.com

By default, the directory is blue and difficult to see, so we will use "ColorTool" to make it easier to see.

procedure

  1. Go to Download Page
  2. Download and unzip the zip file
  3. Shift-click and right-click on the solved folder to "Open PowerShell window here."

▼ Postscript (from here)

The binary distribution of "ColorTool.exe" is no longer available.... I had no choice but to build it using the free version of VisualStudio, following the procedure below.

  1. Install Visual Studio Community edition
  2. Download Under the ColorTool folder from Github
  3. Execute .\build.bat rel in PowerShell, etc.
  4. ColorTool/bin/Release/xxx/ColorTool.exe" is created.
  5. Place the "schemes" folder in the same folder as the created "ColorTool.exe
  6. Schemes are specified by "ColorTool.exe -b . \Јschemes\xxx.ini".

Note: Since "build.bat" looks for and sets the location of "msbuild.exe", if you installed Visual Studio in a different folder than the default, you must manually modify the MSBUILD to become "msbuild.exe" in the installation directory.

▲Addendum (so far)

The list of schemes is displayed with .\ColorTool.exe -s, and . \ColorTool.exe -b <scheme name>. is used to apply the scheme. (To revert, apply the default scheme "cmd-legacy".)

WSLのWindowsのフォルダの色が見づらいのを直す
組み込みスキーム一覧
WSLのWindowsのフォルダの色が見づらいのを直す
スキーム「OneHalfDark」を適用したPowerShell
When I re-launch WSL, the WSL color has also changed.

WSLのWindowsのフォルダの色が見づらいのを直す
スキーム「OneHalfDark」を適用したWSL
Compared to the first, it is much easier to see.

Scheme addition

Schemes can be added by adding files to the "schemes" folder.

There are a lot of scheme files in "schemes" in this way (direction close to the speaker or towards the speaker), but there are too many to be embedded....

Impressions, etc.

I don't like to customize too much, and I had been trying with the default for a long time, but when I used a laptop with a small screen, I couldn't read the text.... I had no choice but to customize it.

Since the binary distribution of ColorTool is no longer available, it is no longer easy at all...

ColorTool is included in the recently announced "Windows Terminal", so I wonder if the binary distribution will be at the release of "Windows Terminal"...

forest.watch.impress.co.jp

Reference Articles

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com

www.ekwbtblog.com