Color issues with zsh in wsl

So, I'm trying to configure oh-my-zsh inside the wsl terminal (using powershell as the console here, but I get the same problem in cmd). I think I set all my colors correctly: enter image description here

And when I ran this:

print -P '%B%F{red}co%F{green}lo%F{blue}rs%f%b'

I get the expected: enter image description here

But my clue is still not the way you can tell. I am using the agnoster theme, and the gray background on pwd should be blue.

Is there a way to see escape sequences so that I can determine if the problem is with the escape sequence versus rendering them?

+8
terminal powershell zsh windows-subsystem-for-linux oh-my-zsh
source share
1 answer

We could learn $PROMPT (or $PS1 ).

Indeed, the oh-my-zsh agnoster theme uses PROMPT_SUBST for her. Thus, we can get the original escape sequences with a redirect or print -P output pipeline:

 $ print $PROMPT %{%f%b%k%}$(build_prompt) $ print -P $PROMPT | cat -v ;# or redirect to a file as you like ^[[39m^[[0m^[[49m^[[40m^[[39m me@mycomputer ^[[44m^[[30mM-nM-^BM-0^[[30m ~ ^[[49m^[[34mM-nM-^BM-0^[[39m 

These are the original escape sequences; ANSI escape codes are well described at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors . These are CSI codes CSI CSI nm SGR - a choice of graphic rendering.

Try to describe the above output:

( ^[[39m : the first two characters are escaped by cat -v . We have ESC[39m .)

  • ^[[39m^[[0m^[[49m : from %{%f%k%b%} of the print $PROMPT output part. ^[[39m to reset the foreground background color, ^[[0m reset each effect and [[49m to reset the default background color.
  • ^[[40m^[[39m me@mycomputer : black color bg and color fg
  • ^[[44m^[[30m M-nM-^BM-0 : default color is bg blue and fg ( M-nM-^BM-0 is cat -v escaped form ξ‚°)

At this point, it seems that the invitation displays bg blue code for pwd. You can check with print -P '%b%F{red}co%F{green}lo%F{blue}rs%f%b' (Note: first "% b")

This means that the powershell color palette setting does not match ANSI escape sequences. We could check if the terminal color 16colors.sh setting is correct or not 16colors.sh in xterm if we have sh viewing the output of sh ./16colors.sh . (For example, an example of the default output xterm can be found, for example: https://www.in-ulm.de/~mascheck/various/xterm/16-table.html )

Your PowerShell Solarized (?) Theme seems to display the ansi blue color sequence ( ^[[44m or ^[[34m ) as a grayish for our eyes.

+2
source share

All Articles