1

I'm using zsh with prompt fade, I do not have oh-my-zsh installed.

My terminal background is dark blue, not black, but the prompt is being printed on a black background.

How can I overwrite this so that the prompt uses the same background color as the rest of the terminal?

FWIW, I have RPS1 set up in .zshrc and that uses the correct bg color.

RPS1='[%F{yellow}%?%f] '
1

zsh doesn't change the background nor foreground colour unless you ask it to.

So, if your prompt background is not the default colour, it's because you, or some of the prompt theme or third party customisation extensions you've enabled have configured it to do so.

In prompt expansion, background colour is changed with %K{colour} and %k (same as %K{default}), though could also be changed by embedding hard coded escape sequences such as $'%{\e[40;37;1m%}foo%{\e[m%}' for a bold white on black foo on most terminals.

And there's %S for standout mode (stopped with %s) which on most terminals is done using reverse video (swap background and foreground colours).

So, if you want to keep the default background colour, you'd need to remove those from the definition of your $PS1 (aka $PROMPT) variable.

Also note that if the promptsubst option is enabled and your $PS1 contains things like $(some command) or ${some_variable}, those will be expanded upon prompt expansion, so you'd also need to watch for colour changing sequences in there as well.

You indicate that you're using the fade prompt theme. The $PS1 variable in that theme by default is:

%F{green}%B%K{green}█▓▒░%F{white}%K{green}%B%n@%m%b%F{green}%K{black}█▓▒░%F{white}%K{black}%B %D{%a %b %d} %D{%I:%M:%S%P}
%}%F{green}%K{black}%B%~/%b%k%f

Where you see the %K{black}. If you look at the definition of the prompt_fade_setup function or run prompt -h fade, you can see that colour is not amongst the things it lets you customize. So if you don't like that black background, you can either

  • switch to a different theme
  • create your own prompt theme based on that one (see info zsh "prompt themes" for details about that).
  • add PS1=${PS1//\%K{black}/%k} after prompt fade in your ~/.zshrc
  • don't use prompt fade, and just copy that PS1 variable definition to your ~/.zshrc with the %K{black} replaced with %k.
| improve this answer | |

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.