1

I just switched from bash to zsh and now I am trying to find out, how to colorize the Username and Host to have different color shemes. With bash my colorsheme looked like that: (orange)user (blue)@ (red)hostname

I couldn't find any good guide or explanation on how to seperate this and when I look at my actual .zshrc

 if [ "$color_prompt" = yes ]; then
 PROMPT=$'%F{%(#.blue.green)}┌──${debian_chroot:+($debian_chroot)──}(%B%F{%(#.red.blue)}%n%(#.💀.㉿)%m%b%F{%(#.    blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\n└─%B%(#.%F{red}#.%F{blue}$)%b%F{reset} '
 RPROMPT=$'%(?.. %? %F{red}%B⨯%b%F{reset})%(1j. %j %F{yellow}%B⚙%b%F{reset}.)'

I can't figure out, what could be the current user and host color.

1
  • Try info zsh 'prompt expansion'. You may need to install a zsh-doc package or equivalent. Aug 31, 2020 at 7:06

1 Answer 1

0
%F{%(#.red.blue)}%n
  • %n expands to your account name, so the colour set immediately before that is what matters.
  • %F expands to the control sequence that sets the foreground colour to whatever is enclosed by the braces, which can be a colour name such as blue amongst other things.
  • %(#.red.blue) is a ternary prompt expansion, that tests the shell process's current user ID (specified by the #) against zero (by default), and expands to red for user ID zero and blue otherwise.

Further reading

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.