Git Product home page Git Product logo

Comments (17)

romkatv avatar romkatv commented on July 17, 2024

Please post your config (the POWERLEVEL9K variables that you set).

from powerlevel10k.

romkatv avatar romkatv commented on July 17, 2024

I'll assume it's the same as in #17. Please tell me if I'm wrong.

from powerlevel10k.

romkatv avatar romkatv commented on July 17, 2024

I reproduced it with your old config. Debugging...

from powerlevel10k.

tjquillan avatar tjquillan commented on July 17, 2024

You sir are amazing! Already debugging the issue before I had the chance to post a slightly altered config (For the most part it is the same though).

from powerlevel10k.

romkatv avatar romkatv commented on July 17, 2024

Fixed. Sorry about breaking your theme for the second time.

from powerlevel10k.

romkatv avatar romkatv commented on July 17, 2024

When debugging the two issues you raised, I got to see how your prompt looks like and I was impressed. Yesterday I decided to restyle my prompt in a similar fashion -- without background and all that junk. I discovered that vcs styling isn't flexible enough. You had to resort to hacks (embedding color tags in icons) that don't always work as intended. For example, you get %F{011}%B<%b%f3% for 3 outgoing changes, with 3 unstyled. Plus, you cannot make your prompt grey when it's being refreshed in the background. So I went and added a few options that allow you to fix these problems.

Here's what you need to set to take advantage of the new features. First, turn off background from LOADING state and make its foreground grey. Without these options your git prompt will look awful in a large git repo (it does look awful now).

POWERLEVEL9K_VCS_LOADING_BACKGROUND=none
POWERLEVEL9K_VCS_LOADING_FOREGROUND=244
POWERLEVEL9K_VCS_LOADING_ACTION_FOREGROUND=244

(The third option is necessary because of backward compatibility.)

Next, take advantage of the new styling options I added. Instead of this:

POWERLEVEL9K_VCS_UNTRACKED_ICON='%F{009}%B?%b%f'

Do this:

typeset POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_UNTRACKED_FOREGROUND=009
POWERLEVEL9K_VCS_UNTRACKED_ICON='%B?%b'

I didn't add an option for bold because embedding bold tags in icons is not as bad as embedding colors. The only imperfection is that you'll have %B<%b3 in your prompt when you have 3 outgoing changes. Ideally, 3 would also be bold. But at least your LOADING prompts will be grey now.

FWIW, I used different color coding for git prompt components than what you have. Since ? means there are untracked files, I set its color to be the same as POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND. Likewise for !, which in my config has the same color as POWERLEVEL9K_VCS_MODIFIED_FOREGROUND. Stash and incoming/outgoing changes don't make your repo dirty, so I set their color to POWERLEVEL9K_VCS_CLEAN_FOREGROUND. It feels very natural. You can take a look at my whole config in https://github.com/romkatv/dotfiles-public/blob/master/.zshrc.

If you like, you can now use different color for every component (local branch, remote branch, stash, etc.) in every state. Hopefully the format is clear from the snippet I posted above.

from powerlevel10k.

tjquillan avatar tjquillan commented on July 17, 2024

Glad you liked the prompt! This improvement is amazing in terms of customization and readability. However as a suggestion, POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}UNTRACKED_FOREGROUND could be better renamed to POWERLEVEL9K_VCS{CLEAN,UNTRACKED,MODIFIED}_UNTRACKED_ICON_FOREGROUND for improved readability. Additionally, I have made a possible issue #33 that may or may not actually be an issue depending on my understanding of you implementation (Please close if its a non-issue).

from powerlevel10k.

romkatv avatar romkatv commented on July 17, 2024

The naming of options is consistent with the existing styling options. FOO_FOREGROUND specifies foreground for segment FOO. FOO_VISUAL_IDENTIFIER_COLOR specifies foreground for the icon used in segment FOO. If FOO_VISUAL_IDENTIFIER_COLOR isn't set, the icon has the same color as the text in the segment.

The options I added are of the FOO_FOREGROUND variety -- they color both the icon and the text. Some components don't have text, but this doesn't break the rule. Most components have both an icon and a text: commit, local branch, remote branch, incoming changes, stashes, etc.

In the future I can also add FOO_VISUAL_IDENTIFIER_COLOR options for git components, which will allow you to style < and 3 in your outgoing changes component differently. It's fairly easy. Likewise, I can add FOO_BOLD=true that will work for anything for which you can set FOO_FOREGROUND (whole segments, or git components), and it'll make the thing bold. It's also fairly easy.

from powerlevel10k.

horseinthesky avatar horseinthesky commented on July 17, 2024

Excuse me. I have the same issue with POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR Not Applied but I don't see how you guys fix it.

I have this line in cfg:

POWERLEVEL9K_DIR_PATH_SEPARATOR="%F{black} $(print_icon 'LEFT_SUBSEGMENT_SEPARATOR') %F{black}"

both 9K and 10K shows

print_icon 'LEFT_SUBSEGMENT_SEPARATOR'


9K shows it

echo $POWERLEVEL9K_DIR_PATH_SEPARATOR
%F{black}  %F{black}

and 10K does not

echo $POWERLEVEL9K_DIR_PATH_SEPARATOR
%F{black}  %F{black}

from powerlevel10k.

romkatv avatar romkatv commented on July 17, 2024

@horseinthesky Please post your config, including the line line where you define POWERLEVEL9K_MODE and where you source powerlevel9k/10k.

from powerlevel10k.

horseinthesky avatar horseinthesky commented on July 17, 2024

@romkatv Here it is sir

POWERLEVEL9K_MODE='nerdfont-complete'
ZSH_THEME=powerlevel10k/powerlevel10k

# ==== Powerlevel9k Settings ====
# Host block settings
POWERLEVEL9K_HOST_ICON='\uF109' # 
POWERLEVEL9K_SSH_ICON='\uF489' # 

# Detect SSH connection
zsh_detect_ssh(){
    if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
        echo -n "\uF489 $HOST"
    else
        echo -n "$(print_icon 'HOST_ICON') $HOST"
    fi
}

# Custom ssh settings
POWERLEVEL9K_CUSTOM_DETECT_SSH="zsh_detect_ssh"
POWERLEVEL9K_CUSTOM_DETECT_SSH_BACKGROUND="paleturquoise4" # 066
POWERLEVEL9K_CUSTOM_DETECT_SSH_FOREGROUND="yellow" # 003

# OS block settings
POWERLEVEL9K_LINUX_UBUNTU_ICON='\UF30C' # 
if [ -f /etc/os-release ]; then
    # freedesktop.org and systemd
    . /etc/os-release
    if [[ $ID == 'ubuntu' ]]; then
        OS_ICON='\uF30C' # 
        POWERLEVEL9K_OS_ICON_BACKGROUND='208' # darkorange
        POWERLEVEL9K_OS_ICON_FOREGROUND='white' # 007
    elif [[ $ID == 'centos' || $ID == 'redhat' ]]; then
        OS_ICON='\uF309' # 
        POWERLEVEL9K_OS_ICON_BACKGROUND='000' # black
        POWERLEVEL9K_OS_ICON_FOREGROUND='red' # 001
    fi
fi

# User block settings
POWERLEVEL9K_USER_ICON='\uF415' # 
# POWERLEVEL9K_ROOT_ICON="\uF198" # 
POWERLEVEL9K_ROOT_ICON='\uF09C' # 
POWERLEVEL9K_USER_DEFAULT_BACKGROUND='plum4' # 096
POWERLEVEL9K_USER_DEFAULT_FOREGROUND='white' # 007
POWERLEVEL9K_USER_ROOT_BACKGROUND='darkred' # 088
POWERLEVEL9K_USER_ROOT_FOREGROUND='white' # 007
# RED_HAT_ICON='\uF309' # 
# LINUX_ICON='\uE712' # 

# Home block settings
POWERLEVEL9K_HOME_ICON=''
POWERLEVEL9K_HOME_SUB_ICON=''
POWERLEVEL9K_FOLDER_ICON=''

# Dir block settings
POWERLEVEL9K_DIR_PATH_SEPARATOR="%F{black} $(print_icon 'LEFT_SUBSEGMENT_SEPARATOR') %F{black}"
# POWERLEVEL9K_SHORTEN_STRATEGY="truncate_middle"
# POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\UE0BC'
# POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\UE0BA'
# POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0B4'
# POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\uE0B6'
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_DELIMITER='..'
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='dodgerblue1'
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND='black'
POWERLEVEL9K_DIR_HOME_BACKGROUND='dodgerblue1'
POWERLEVEL9K_DIR_HOME_FOREGROUND='black'
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND='dodgerblue1'
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND='black'
POWERLEVEL9K_DIR_ETC_BACKGROUND='lightseagreen'
POWERLEVEL9K_DIR_ETC_FOREGROUND='black'

# Dir Writable settings
# POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR=''
POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_BACKGROUND='red3' # 160
POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_FOREGROUND='yellow1' # 226

# VCS settings
POWERLEVEL9K_VCS_BRANCH_ICON='\uF126 '
POWERLEVEL9K_VCS_GIT_GITHUB_ICON='\uF408 '
POWERLEVEL9K_VCS_STAGED_ICON='\u00b1'
POWERLEVEL9K_VCS_UNTRACKED_ICON='\u25CF'
POWERLEVEL9K_VCS_UNSTAGED_ICON='\u00b1'
POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='\u2193'
POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='\u2191'
POWERLEVEL9K_VCS_COMMIT_ICON='\uf417'

# Virtualenv block settings
POWERLEVEL9K_VIRTUALENV_FOREGROUND='blue' # 004
POWERLEVEL9K_VIRTUALENV_BACKGROUND='gold1' # 220
POWERLEVEL9K_PYTHON_ICON='\uE606'

# Pyenv block settings
POWERLEVEL9K_PYENV_FOREGROUND='blue' # 004
POWERLEVEL9K_PYENV_BACKGROUND='gold1' # 220
# POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=true

# Time block settings
POWERLEVEL9K_TIME_FORMAT="%D{\uf017 %H:%M \uf073 %d.%m.%y}"

# Prompt settings
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon custom_detect_ssh user dir_writable dir virtualenv pyenv)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(vcs)
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
# POWERLEVEL9K_RPROMPT_ON_NEWLINE=true
# POWERLEVEL9K_DISABLE_RPROMPT=true
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%F{$POWERLEVEL9K_OS_ICON_BACKGROUND}\u256D\u2500"
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{$POWERLEVEL9K_OS_ICON_BACKGROUND}\u2570\uf460%F{default} "

from powerlevel10k.

romkatv avatar romkatv commented on July 17, 2024

The config you've posted doesn't source powerlevel9/10k neither directly nor indirectly. Judging by the presence of ZSH_THEME I suppose you are using Oh-My-Zsh? Where do you have source $ZSH/oh-my-zsh.sh?

The reason I'm asking is that your definition of POWERLEVEL9K_DIR_PATH_SEPARATOR contains a function call. Specifically, it calls print_icon, which is defined in powerlevel9k/10k. However, calling a function before it's defined will give you empty output (and an error message).

from powerlevel10k.

horseinthesky avatar horseinthesky commented on July 17, 2024

@romkatv Correct I'm using Oh-My-Zsh and I have source $ZSH/oh-my-zsh.sh after ZSH_THEME and before POWERLEVEL settings.

I didn't provide the whole config because of the huge amount of default comments in it.

print_icon works:

print_icon 'LEFT_SUBSEGMENT_SEPARATOR'


but this variable is missing the separator:

echo $POWERLEVEL9K_DIR_PATH_SEPARATOR
%F{black}  %F{black}

from powerlevel10k.

romkatv avatar romkatv commented on July 17, 2024

I managed to reproduce this and submitted a fix in f5c2bf1.

By the way, your config will be simpler and won't rely on this subtle behavior if you do it this way:

POWERLEVEL9K_DIR_PATH_SEPARATOR=' \uE0B1 '

Consistent with your other options, too.

P.S.

The reason of the original bug is that Powerlevel10k tries to be accommodating towards users who define POWERLEVEL9K options after sourcing the theme. This isn't officially supported but it happens frequently enough that I made it work. Unfortunately, Powerlevel9k documentation exposes the internal print_icon function, so some users use that. Ironically, it forces users use define options after sourcing the theme, which means that a random half of their options won't have any effect in Powerlevel9k.

P.P.S.

Thanks for the bug report!

from powerlevel10k.

horseinthesky avatar horseinthesky commented on July 17, 2024

@romkatv Wow. That was definitely the most urgent fix I have ever seen in my life =)
Thank you so much. Not it works great. And btw it's insanely fast.

Since I don't think I would return to 9K should I change my config in any way to be more 10K compatible?

from powerlevel10k.

romkatv avatar romkatv commented on July 17, 2024

Since I don't think I would return to 9K should I change my config in any way to be more 10K compatible?

The change I suggested will work equally well with 9k and 10k. Without the change it should also work in both themes (it was a bug in 10k what was causing your config to malfunction in 10k).

from powerlevel10k.

horseinthesky avatar horseinthesky commented on July 17, 2024

Ok. Thanks again!

from powerlevel10k.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.