powerlevel10k: Inconsistent space between segments depending on the background color of a custom p10k segment
Hello. I am trying to add a custom segment called drd_dev_env. I have it at the end of my POWERLEVEL9K_LEFT_PROMPT_ELEMENTS like this:
# =========================[ Line #2 ]=========================
drd_dev_env # Development environment: prod/staging/test
context # user@hostname
prompt_char # prompt symbol
)
If I define an empty background color, there is a space between this segment and context:
typeset -g POWERLEVEL9K_DRD_DEV_ENV_BACKGROUND=
function prompt_drd_dev_env() {
if [[ ! -z $DRD_DEV_ENV ]]; then
p10k segment -f white -t "$DRD_DEV_ENV"
fi
}
However, if I define a non-empty background color, there is not a space between this segment and context:
typeset -g POWERLEVEL9K_DRD_DEV_ENV_BACKGROUND='black'
function prompt_drd_dev_env() {
if [[ ! -z $DRD_DEV_ENV ]]; then
p10k segment -f white -t "$DRD_DEV_ENV"
fi
}
Is there any way to explicitly control this behavior?
I am using the P10k from git at commit 16e5848.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (8 by maintainers)
Looks good. I’d implement it like this:
You don’t have to use
POWERLEVEL9K_*overrides when working with your own prompt segment. No need to override what you’ve custom made for yourself.My suggestion is to use foreground colors and/or icons to call attention to a segment.
Sure, you can do that, although as I mentioned above, I don’t think it’s a good idea to use background colors with Lean style.
Left prompt segments with the same background color are separated by
POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR. Left prompt segments with different background colors are separated byPOWERLEVEL9K_LEFT_SEGMENT_SEPARATOR. I suppose in your config the former is set to' 'and the latter to''. You can verify with the following command:I also suppose that your config is based on Lean style. It’s a good choice. I also use Lean. In this style you don’t use background colors and convey information by content, icons and foreground colors only.