I can easily switch back to the terminal default coloring scheme using %k
(background) or %f
(foreground). There is also the option to use %K(default)
or %F(default)
which produces the same results.
How can I change the foreground color to the default background color? Is this even possible without exactly naming the color-code?
Usage example: coloring the left-facing powerline separator correctly: ⮂. (leftern side is background color, rightern side is foreground color)
You can switch foreground and background colors with the standout mode %S (%s)
.
In order to print something in the default background color, you just have to set background color to default, foreground color to whatever you want as background and enable standout mode.
Examples:
print -P $' unchanged output colors'
print -P $'%f%k default colors %S standout mode %s'
print -P $'%F{blue}%K{red} blue on red %f%k'
print -P $'%S%F{blue}%K{red} red on blue %s blue on red %f%k'
print -P $'%K{default}%F{blue}%Sdefault background on blue %s%f%k'
print -P $'%K{red}%F{default}%S red on default foreground %f%k%s'
As you can see, it does not matter in which order the colors and modes (works the same for boldface and underline modes) are set. You can set a foreground color with %F{color}
before or after starting standout mode with %S
, it is just used as background after %S
until you stop standout mode with %s
.