romkatv / powerlevel10k

A Zsh theme
MIT License
45.91k stars 2.17k forks source link

Powerlevel10k prompt color match to terminal theme automatically #1858

Closed ciscohack closed 2 years ago

ciscohack commented 2 years ago

Hello Experts,

Is there a way or is it possible for powerlevel10k to pick up the prompt color based on a terminal theme to present and beautiful prompt look? I am using the solarized dark theme for my alacritty/kitty terminal and noticed prompt color is not cool. But I have seen other people using same theme and they have very beautiful prompt

check the example of a prompt with a solarized dark theme.

image

Here above we can see prompt pick the blue and yellow color for prompt accordingly solarized theme but in my case prompt looks ugly with same theme

image

Can I fix this? I know we have background and foreground color change options in the .p10z.zsh config but that's need lot of manual work and we can't come close to color it shows in top screenshot

romkatv commented 2 years ago

Does this answer your questions? https://github.com/romkatv/powerlevel10k#how-do-i-change-prompt-colors

ciscohack commented 2 years ago

Does this answer your questions? https://github.com/romkatv/powerlevel10k#how-do-i-change-prompt-colors

Thanks, Roman for the quick response. I have checked this before knocking on your door for help. So basically to match the prompt color like the screenshot. I have to rebuild the p10k configure with the following mentioned steps. am I correct here if I have not chosen this method then not possible to match the prompt right. I played with Background and foreground colors but the result is very bad text is unreadable.

I am just checking if someone chooses a higher color then is it possible in future powerlevel10k releases it pick the better color for prompt

p10k configure and select Rainbow, Lean → 8 colors, or Pure → Original

image

ciscohack commented 2 years ago

@romkatv what LS_COLOR expert setting do you use for better results. is it possible for your to share. I have LS_COLOR script but that has a very wide color range and does not blend nicely with my prompt.

romkatv commented 2 years ago

So basically to match the prompt color like the screenshot. I have to rebuild the p10k configure with the following mentioned steps.

The prompt on the screenshot is agnoster. You can use it instead of powerlevl10k if you like it.

You can make powerlevel10k look exactly the same but it requires quite a bit of manual configuration. The following should get you fairly close:

unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
POWERLEVEL9K_MODE=powerline
POWERLEVEL9K_STATUS_OK=false
POWERLEVEL9K_STATUS_ERROR_CONTENT_EXPANSION=
POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘'

[[ ! -v functions[p10k] ]] || p10k reload

You need to replace your ~/.p10k.zsh with this content.

@romkatv what LS_COLOR expert setting do you use for better results.

I use zsh4humans, which has the following defaults:

# LS_COLORS is used by GNU ls and Zsh completions. LSCOLORS is used by BSD ls.
export LS_COLORS='fi=00:mi=00:mh=00:ln=01;36:or=01;31:di=01;34:ow=04;01;34:st=34:tw=04;34:'
LS_COLORS+='pi=01;33:so=01;33:do=01;33:bd=01;33:cd=01;33:su=01;35:sg=01;35:ca=01;35:ex=01;32'
export LSCOLORS='ExGxDxDxCxDxDxFxFxexEx'

if (( terminfo[colors] >= 256 )); then
  LS_COLORS+=':no=38;5;248'
  ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=244'        # the default is hard to see
else
  LS_COLORS+=':no=1;30'
  ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=black,bold' # the default is outside of 8-color range
fi

# TREE_COLORS is used by GNU tree. It looks awful with underlined text, so we turn it off.
export TREE_COLORS=${LS_COLORS//04;}

As for prompt, I use Lean style with two lines, sparse, transient prompt and few icons. See https://github.com/romkatv/powerlevel10k#what-is-the-best-prompt-style-in-the-configuration-wizard.

I use Tango Dark terminal theme (rather than Solarized Dark from your screenshot) with a custom background color. See https://github.com/romkatv/powerlevel10k#how-were-these-screenshots-and-animated-gifs-created. On macOS I use Apple Terminal (rather than iTerm from your screenshot). Here's my config for Apple Terminal, which includes the color scheme: https://github.com/romkatv/dotfiles-public/blob/master/dotfiles/apple-terminal-profile.terminal

ciscohack commented 2 years ago

@romkatv Sir you are great this powerlevel10k is so flexible one who knows how to can do anything ... with your small config, I am able to get that theme color and prompt close to agnoster Thanks for it..

I never thought the config will be so small ... is their any good tutorial on powerlevel10 how to create different customization prompt like if one want robbyrussel theme or spaceship prompt style he can do small change and get it done. which only section need to change to get close to any prompt.

like If I want to create prompt like this image

# LS_COLORS is used by GNU ls and Zsh completions. LSCOLORS is used by BSD ls.
export LS_COLORS='fi=00:mi=00:mh=00:ln=01;36:or=01;31:di=01;34:ow=04;01;34:st=34:tw=04;34:'
LS_COLORS+='pi=01;33:so=01;33:do=01;33:bd=01;33:cd=01;33:su=01;35:sg=01;35:ca=01;35:ex=01;32'
export LSCOLORS='ExGxDxDxCxDxDxFxFxexEx'

if (( terminfo[colors] >= 256 )); then
  LS_COLORS+=':no=38;5;248'
  ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=244'        # the default is hard to see
else
  LS_COLORS+=':no=1;30'
  ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=black,bold' # the default is outside of 8-color range
fi

# TREE_COLORS is used by GNU tree. It looks awful with underlined text, so we turn it off.
export TREE_COLORS=${LS_COLORS//04;}

Above the LS_COLOR setting, you put in zshrc to apply LS_COLOR globally, or should I put in p10k.zsh...

romkatv commented 2 years ago

is their any good tutorial on powerlevel10 how to create different customization prompt like if one want robbyrussel theme or spaceship prompt style he can do small change and get it done

None that I know of.

Above the LS_COLOR setting, you put in zshrc to apply LS_COLOR globally, or should I put in p10k.zsh...

LS_COLOR has nothing to do with powerlevel10k or prompt in general, so there is no reason to put it in ~/.p10k.zsh. The latter is meant to contain configuration options for powerlevel10k.

ciscohack commented 2 years ago

@romkatv Thanks for clarifying about LS_COLOR config .. i will put the config in my zshrc file then.

is this prompt style also possible to replicate in powerlevel10k.. in future releases can you include more options to style prompt through p10k configure .. currently we have lean/classing/rainbow/pure styles

image

romkatv commented 2 years ago

is this prompt style also possible to replicate in powerlevel10k.

Yes. You can get it pretty close by choosing Rainbow style in p10k configure and picking appropriate heads, tails and separators. After that you'll need to manually tweak colors and icons.

Note that this screenshot has whitespace-related bugs. You can replicate these bugs in powerlevel10k, too.

in future releases can you include more options to style prompt through p10k configure

It's not among my plans.

ciscohack commented 2 years ago

is this prompt style also possible to replicate in powerlevel10k.

Yes. You can get it pretty close by choosing Rainbow style in p10k configure and picking appropriate heads, tails and separators. After that you'll need to manually tweak colors and icons.

Note that this screenshot has whitespace-related bugs. You can replicate these bugs in powerlevel10k, too.

in future releases can you include more options to style prompt through p10k configure

It's not among my plans.

I can understand your point and challenge to include a more prompt style in p10k configure. Thanks anyway. I will try the rainbow style as you suggested with a low color range ..let see if I able to replicate but I am sure I will not get close as you do with precision and a blink of a second. Thanks once again Sir!

romkatv commented 2 years ago

I am sure I will not get close as you do with precision and a blink of a second

I cannot get close without expending significant effort. The most time-consuming part is reverse-engineering colors and icons.