You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This could be user error, but I'm noticing that, while termenv will correctly detect TrueColor in Windows Terminal, it incorrectly detects ANSI256, in WSL.
To know if WSL is being used inside Windows Terminal. One can do:
// Detect WSL as it has True Color supportwsl, err:=ioutil.ReadFile("/proc/sys/kernel/osrelease")
// Additional check needed for Mac Os as it doesn't have "/proc/" folderiferr!=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 twiceifstring(wsl) !="" {
wslLower:=strings.ToLower(string(wsl))
// Also check if the terminal used is Windows Terminalifstrings.Contains(wslLower, "Microsoft") &&os.GetEnv("WT_SESSION") !=0 {
returnterminfo.ColorLevelMillions
}
}
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: