-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Color detection error in WSL in Windows Terminal #124
Comments
meowgorithm
changed the title
Inconsistent Detection in WSL in Windows Terminal
Color detection error in WSL in Windows Terminal
Mar 10, 2023
I'll see if we can reliably detect WSL inside Windows Terminal and add a special case for its TrueColor support. |
To know if WSL is being used inside Windows Terminal. One can do: // Detect WSL as it has True Color support
wsl, err := ioutil.ReadFile("/proc/sys/kernel/osrelease")
// Additional check needed for Mac Os as it doesn't have "/proc/" folder
if err != nil && !errors.Is(err, os.ErrNotExist) {
log.Fatal(err)
}
// Lowercasing every content inside "/proc/sys/kernal/osrelease"
// because it gives "Microsoft" for WSL and "microsoft" for WSL 2
// so no need of checking twice
if string(wsl) != "" {
wslLower := strings.ToLower(string(wsl))
// Also check if the terminal used is Windows Terminal
if strings.Contains(wslLower, "Microsoft") && os.GetEnv("WT_SESSION") != 0 {
return terminfo.ColorLevelMillions
}
} @muesli I can work on this issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This could be user error, but I'm noticing that, while termenv will correctly detect
TrueColor
in Windows Terminal, it incorrectly detectsANSI256
, in WSL.Given this code...
...I get the following output. The first line shows
example.exe
running in PowerShell and then in WSL.The text was updated successfully, but these errors were encountered: