Comments (7)
Are the following variables still used?
#typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='yellow' #typeset -g POWERLEVEL9K_VCS_MODIFIED_BRANCHFORMAT_FOREGROUND=8
Commented out variables have no effect. If you uncomment them, they might or might not have effect. It depends on the rest of your configuration.
If you can attach your existing config as a file and describe what you are trying to achieve, I'll be able to show you how. Something like this: "Everything about vcs
segment satisfies me as is except for the foreground color of the content and the icon. When the repo is clean, I want the foreground color to be black, etc."
from powerlevel10k.
Here my configuration. Sorry for the comment, in copy/paste i took the wrong version of the config.
I want that the whole text of vcs segment change accordingl to the git status.
If the repo is clean I want blue color for bg and white color for fg
When the repo is modified I want yellow for bg and black for fg.
Thanks in advance
#####################################[ vcs: git status ]######################################
# Version control background colors.
typeset -g POWERLEVEL9K_VCS_CLEAN_BACKGROUND=4
typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=7
typeset -g POWERLEVEL9K_VCS_CLEAN_BRANCHFORMAT_FOREGROUND=7
typeset -g POWERLEVEL9K_VCS_MODIFIED_BACKGROUND=11
typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='black'
typeset -g POWERLEVEL9K_VCS_MODIFIED_BRANCHFORMAT_FOREGROUND=0
typeset -g POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND=41
typeset -g POWERLEVEL9K_VCS_CONFLICTED_BACKGROUND=11
typeset -g POWERLEVEL9K_VCS_LOADING_BACKGROUND=238
# Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon.
typeset -g POWERLEVEL9K_VCS_BRANCH_ICON='\uF126 '
# typeset -g POWERLEVEL9K_VCS_BRANCH_ICON='\UE0A0 '
# Untracked files icon. It's really a question mark, your font isn't broken.
# Change the value of this parameter to show a different icon.
typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?'
# Formatter for Git status.
#
# Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42.
#
# You can edit the function to customize how Git status looks.
#
# VCS_STATUS_* parameters are set by gitstatus plugin. See reference:
# https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh.
function my_git_formatter() {
emulate -L zsh
if [[ -n $P9K_CONTENT ]]; then
# If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from
# gitstatus plugin). VCS_STATUS_* parameters are not available in this case.
typeset -g my_git_format=$P9K_CONTENT
return
fi
# Styling for different parts of Git status.
local meta='%7F' # white foreground
local clean='%0F' # black foreground
local modified='%0F' # black foreground
local untracked='%0F' # black foreground
local conflicted='%1F' # red foreground
local res
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
local branch=${(V)VCS_STATUS_LOCAL_BRANCH}
# If local branch name is at most 32 characters long, show it in full.
# Otherwise show the first 12 … the last 12.
# Tip: To always show local branch name in full without truncation, delete the next line.
(( $#branch > 32 )) && branch[13,-13]="…" # <-- this line
res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
fi
if [[ -n $VCS_STATUS_TAG
# Show tag only if not on a branch.
# Tip: To always show tag, delete the next line.
&& -z $VCS_STATUS_LOCAL_BRANCH # <-- this line
]]; then
local tag=${(V)VCS_STATUS_TAG}
# If tag name is at most 32 characters long, show it in full.
# Otherwise show the first 12 … the last 12.
# Tip: To always show tag name in full without truncation, delete the next line.
(( $#tag > 32 )) && tag[13,-13]="…" # <-- this line
res+="${meta}#${clean}${tag//\%/%%}"
fi
# Display the current Git commit if there is no branch and no tag.
# Tip: To always display the current Git commit, delete the next line.
[[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line
res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
# Show tracking branch name if it differs from local branch.
if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then
res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}"
fi
# Display "wip" if the latest commit's summary contains "wip" or "WIP".
if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then
res+=" ${modified}wip"
fi
if (( VCS_STATUS_COMMITS_AHEAD || VCS_STATUS_COMMITS_BEHIND )); then
# ⇣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}"
elif [[ -n $VCS_STATUS_REMOTE_BRANCH ]]; then
# Tip: Uncomment the next line to display '=' if up to date with the remote.
# res+=" ${clean}="
fi
# ⇠42 if behind the push remote.
(( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}"
(( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" "
# ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42.
(( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_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}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
# "─" if the number of unstaged files is unknown. This can happen due to
# POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower
# than the number of files in the Git index, or due to bash.showDirtyState being set to false
# in the repository config. The number of staged and untracked files may also be unknown
# in this case.
(( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─"
typeset -g my_git_format=$res
}
functions -M my_git_formatter 2>/dev/null
# Don't count the number of unstaged, untracked and conflicted files in Git repositories with
# more than this many files in the index. Negative value means infinity.
#
# If you are working in Git repositories with tens of millions of files and seeing performance
# sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output
# of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's
# config: `git config bash.showDirtyState false`.
typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1
# Don't show Git status in prompt for repositories whose workdir matches this pattern.
# For example, if set to '~', the Git repository at $HOME/.git will be ignored.
# Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'.
typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
# Disable the default Git status formatting.
typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true
# Install our own Git status formatter.
typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter()))+${my_git_format}}'
# Enable counters for staged, unstaged, etc.
typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1
# Custom icon.
typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION=' '
typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=7
# Custom prefix.
# typeset -g POWERLEVEL9K_VCS_PREFIX='on '
# Show status of repositories of these types. You can add svn and/or hg if you are
# using them. If you do, your prompt may become slow even when your current directory
# isn't in an svn or hg repository.
typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
from powerlevel10k.
Please copy ~/.p10k.zsh
to p10k.txt
and attach it as file.
from powerlevel10k.
Attached, thanks
p10k.txt
from powerlevel10k.
Here you go:
--- orig.zsh 2024-02-26 10:46:43.921023000 +0100
+++ new.zsh 2024-02-26 10:46:35.785245700 +0100
@@ -357,13 +357,18 @@
# Version control background colors.
typeset -g POWERLEVEL9K_VCS_CLEAN_BACKGROUND=4
typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=7
- typeset -g POWERLEVEL9K_VCS_CLEAN_BRANCHFORMAT_FOREGROUND=7
- typeset -g POWERLEVEL9K_VCS_MODIFIED_BACKGROUND=11
- typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='black'
- typeset -g POWERLEVEL9K_VCS_MODIFIED_BRANCHFORMAT_FOREGROUND=0
- typeset -g POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND=41
- typeset -g POWERLEVEL9K_VCS_CONFLICTED_BACKGROUND=11
- typeset -g POWERLEVEL9K_VCS_LOADING_BACKGROUND=238
+
+ typeset -g POWERLEVEL9K_VCS_MODIFIED_BACKGROUND=3
+ typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=0
+
+ typeset -g POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND=3
+ typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=0
+
+ typeset -g POWERLEVEL9K_VCS_CONFLICTED_BACKGROUND=3
+ typeset -g POWERLEVEL9K_VCS_CONFLICTED_FOREGROUND=0
+
+ typeset -g POWERLEVEL9K_VCS_LOADING_BACKGROUND=3
+ typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=0
# Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon.
typeset -g POWERLEVEL9K_VCS_BRANCH_ICON='\uF126 '
@@ -391,13 +396,6 @@
return
fi
- # Styling for different parts of Git status.
- local meta='%7F' # white foreground
- local clean='%0F' # black foreground
- local modified='%0F' # black foreground
- local untracked='%0F' # black foreground
- local conflicted='%1F' # red foreground
-
local res
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
@@ -406,7 +404,7 @@
# Otherwise show the first 12 … the last 12.
# Tip: To always show local branch name in full without truncation, delete the next line.
(( $#branch > 32 )) && branch[13,-13]="…" # <-- this line
- res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
+ res+="${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
fi
if [[ -n $VCS_STATUS_TAG
@@ -419,60 +417,60 @@
# Otherwise show the first 12 … the last 12.
# Tip: To always show tag name in full without truncation, delete the next line.
(( $#tag > 32 )) && tag[13,-13]="…" # <-- this line
- res+="${meta}#${clean}${tag//\%/%%}"
+ res+="#${tag//\%/%%}"
fi
# Display the current Git commit if there is no branch and no tag.
# Tip: To always display the current Git commit, delete the next line.
[[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line
- res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
+ res+="@${VCS_STATUS_COMMIT[1,8]}"
# Show tracking branch name if it differs from local branch.
if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then
- res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}"
+ res+=":${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}"
fi
# Display "wip" if the latest commit's summary contains "wip" or "WIP".
if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then
- res+=" ${modified}wip"
+ res+=" wip"
fi
if (( VCS_STATUS_COMMITS_AHEAD || VCS_STATUS_COMMITS_BEHIND )); then
# ⇣42 if behind the remote.
- (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}"
+ (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ⇣${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}"
+ (( VCS_STATUS_COMMITS_AHEAD )) && res+="⇡${VCS_STATUS_COMMITS_AHEAD}"
elif [[ -n $VCS_STATUS_REMOTE_BRANCH ]]; then
# Tip: Uncomment the next line to display '=' if up to date with the remote.
- # res+=" ${clean}="
+ # res+=" ="
fi
# ⇠42 if behind the push remote.
- (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}"
+ (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}"
(( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" "
# ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42.
- (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}"
+ (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}"
# *42 if have stashes.
- (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}"
+ (( VCS_STATUS_STASHES )) && res+=" *${VCS_STATUS_STASHES}"
# 'merge' if the repo is in an unusual state.
- [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}"
+ [[ -n $VCS_STATUS_ACTION ]] && res+=" ${VCS_STATUS_ACTION}"
# ~42 if have merge conflicts.
- (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}"
+ (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ~${VCS_STATUS_NUM_CONFLICTED}"
# +42 if have staged changes.
- (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}"
+ (( VCS_STATUS_NUM_STAGED )) && res+=" +${VCS_STATUS_NUM_STAGED}"
# !42 if have unstaged changes.
- (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}"
+ (( VCS_STATUS_NUM_UNSTAGED )) && res+=" !${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}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
+ (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
# "─" if the number of unstaged files is unknown. This can happen due to
# POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower
# than the number of files in the Git index, or due to bash.showDirtyState being set to false
# in the repository config. The number of staged and untracked files may also be unknown
# in this case.
- (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─"
+ (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ─"
typeset -g my_git_format=$res
}
@@ -501,7 +499,7 @@
# Custom icon.
typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION=' '
- typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=7
+
# Custom prefix.
# typeset -g POWERLEVEL9K_VCS_PREFIX='on '
Note that I gave UNTRACKED
, CONFLICTED
and LOADING
the same colors as MODIFIED
. You can adjust them to your liking.
from powerlevel10k.
This is exactly what i wanted. Thank you. May I take advantage of your availability to ask if is there a way to separate the segment as in the following image
And also, is there a guide or documentation for creating a custom segment?
Thanks again, you're great.
from powerlevel10k.
is there a way to separate the segment as in the following image
Only for classic style but not for rainbow. See #2414.
And also, is there a guide or documentation for creating a custom segment? Thanks again, you're great.
Search for "prompt_example" in ~/.p10k.zsh
and run p10k help segment
.
from powerlevel10k.
Related Issues (20)
- Powerlevel10k is suddenly broken in Intellij IDEA terminal HOT 12
- [WARNING]: Console output during zsh initialization detected for iconv: iconv_open(, -t): Invalid argument HOT 8
- Can not change the os icon background without changing the dir background
- Bug: git `core.excludesfile` is ignored HOT 1
- Error description shows while opening iTerm app HOT 2
- Issues at initial configuration HOT 1
- Git Icons Not Displaying Properly in VSCode HOT 1
- Pop!_OS logo not used
- Project on life support HOT 5
- Azure icon UTF-8 RTL issue HOT 4
- Prompt Color Mismatch After Latest iTerm2 Update HOT 1
- Keep cammand_execution_time on the old prompt even with transient prompt HOT 4
- p10k doesnt load if I switch users HOT 7
- Error converting string from to UTF-8 on Prompt HOT 3
- Autocomplete for brew doesn't work HOT 1
- Git Status not updating in current shell
- Unable to set POWERLEVEL9K_VCS_BRANCH_ICON with Pure HOT 6
- why icon change to the question mark? HOT 2
- Console output during zsh initialization detected HOT 2
- [BUG]No data for SHA256-based git repos HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from powerlevel10k.