On a Raspberry Pi using zsh, I have set PS1=%B%F{#50F862}%n@%m%f%b:%B%F{#625EF6}%~ %#%f%b
to mimic the default bash coloring of ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\]
, since I prefer to use zsh
. This works as-expected when in a usual ssh
session, but when I start a screen
session,the prompt colors are grey.
If I change instead to PS1=%B%F{green}%n@%m%f%b:%B%F{blue}%~ %#%f%b
, then the colors show up as expected (and, I must admit, look pretty indistinguishable - so this isn't a big problem, it's just a curiosity). How do I use hex color codes in a zsh prompt in screen?
Try this:
zmodload zsh/nearcolor
Not all devices and programs support the hex-triplet colors; it looks like screen
may be in the set that can only handle 256 colors, and therefore it doesn't understand the escape codes it's getting. With the nearcolor
module, zsh
will attempt to map the hex color to one of the supported colors.
You can also specify the xterm color directly with %F
and %K
, and avoid loading any modules:
PROMPT='%B%F{93}%n@%m%f%b%F{240}:%f%B%K{112}%~ %#%k%b '