Closed heylookltsme closed 5 years ago
You can do it like this:
POWERLEVEL9K_VCS_UNTRACKED_ICON=$'%{\b?%}'
POWERLEVEL9K_VCS_UNSTAGED_ICON=$'%{\b!%}'
POWERLEVEL9K_VCS_STAGED_ICON=$'%{\b+%}'
I used this hack some time back. It does cause issues in some corner cases though, so I no longer use it.
That seems to work great, thank you!! What sort of issues does it cause?
That seems to work great, thank you!! What sort of issues does it cause?
It breaks prompt if the symbol (such as !
, ?
or +
) is supposed be printed at the last column on the terminal line. This can happen when vcs
segment is put in right prompt, or when left prompt overflows to the next line. These conditions are super rare, and even when they do happen, your zsh will still be usable.
Awesome, that's totally good enough for me then. Thanks much! 💯
By the way, is this the config you are using? https://github.com/heylookltsme/dotfiles/blob/master/.zshrc
It was; it's super out of date now. I got a new computer recently and it looks like a lot needing updating. 🙃
I see that your config is using powerlevel10k rather than powerlevel9k. It's an independent theme, so please file issues and post questions in the future at https://github.com/romkatv/powerlevel10k/.
Powerlevel10k supports custom Git status formatting where you have full control over the content. The new config templates (unlike the old ones, on which your own config is based) allow for relatively straightforward Git status format customization. Here's how you can achieve the format you are after.
p10k configure
to generate a new config.~/.p10k.zsh
and search for my_git_formatter
. This function is responsible for building Git prompt segment from VCS_STATUS_*
parameters set by gitstatus plugin. You'll see the following snippet:
# ⇣42 if behind the remote.
(( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}"
# ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42.
(( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" "
(( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}"
# *42 if have stashes.
(( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}"
# 'merge' if the repo is in an unusual state.
[[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}"
# ~42 if have merge conflicts.
(( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}"
# +42 if have staged changes.
(( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}"
# !42 if have unstaged changes.
(( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}"
# ?42 if have untracked files. It's really a question mark, your font isn't broken.
# See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon.
# Remove the next line if you don't want to see untracked files at all.
(( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
# * if have stashes.
(( VCS_STATUS_STASHES )) && res+="${clean}*"
# ~ if have merge conflicts.
(( VCS_STATUS_NUM_CONFLICTED )) && res+="${conflicted}~"
# + if have staged changes.
(( VCS_STATUS_NUM_STAGED )) && res+="${modified}+"
# ! if have unstaged changes.
(( VCS_STATUS_NUM_UNSTAGED )) && res+="${modified}!"
# ? if have untracked files. It's really a question mark, your font isn't broken.
# See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon.
# Remove the next line if you don't want to see untracked files at all.
(( VCS_STATUS_NUM_UNTRACKED )) && res+="${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}"
# ⇣42 if behind the remote.
(( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}"
# ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42.
(( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" "
(( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}"
# 'merge' if the repo is in an unusual state.
[[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}"
Hopefully it's clear from the comments what's going on, so you can tune the format to your liking.
If something doesn't work quite the way you like, or if you have any questions, please open an issue at https://github.com/romkatv/powerlevel10k/.
Apologies if this is documented somewhere and I simply couldn't find it, but I'm wondering if there's a straightforward way to remove the spacing between the branch name and the various vcs icons for untracked / unstaged / staged status.
I'm hoping that instead of
master + ! ? ⇣1⇡1
, I could havemaster+!? ⇣1⇡1
. In a perfect world, I'd like to keep a space between untracked/unstaged/staged icons and the ahead/behind icons and count.Thanks for your help!