mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-17 02:00:07 +00:00
Merge pull request #220 from dritter/rename_vcs_default_state
Rename vcs default state
This commit is contained in:
commit
b3fae48893
5 changed files with 92 additions and 4 deletions
|
@ -24,4 +24,5 @@ script:
|
||||||
- test/segments/dir.spec
|
- test/segments/dir.spec
|
||||||
- test/segments/rust_version.spec
|
- test/segments/rust_version.spec
|
||||||
- test/segments/go_version.spec
|
- test/segments/go_version.spec
|
||||||
|
- test/segments/vcs.spec
|
||||||
|
|
||||||
|
|
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,5 +1,15 @@
|
||||||
## v0.4.0 (next)
|
## v0.4.0 (next)
|
||||||
|
|
||||||
|
### `vcs` changes
|
||||||
|
|
||||||
|
The default state was renamed to `clean`. If you overrode foreground
|
||||||
|
or background color in the past, you need to rename your variables to:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
|
||||||
|
POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
|
||||||
|
```
|
||||||
|
|
||||||
### `aws_eb_env` added
|
### `aws_eb_env` added
|
||||||
|
|
||||||
This segment displays the current Elastic Beanstalk environment.
|
This segment displays the current Elastic Beanstalk environment.
|
||||||
|
|
|
@ -17,7 +17,7 @@ function +vi-git-untracked() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \
|
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \
|
||||||
-n $(git status ${FLAGS} | grep -E '^??' 2> /dev/null | tail -n1) ]]; then
|
-n $(git status ${FLAGS} | grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then
|
||||||
hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')"
|
hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')"
|
||||||
VCS_WORKDIR_HALF_DIRTY=true
|
VCS_WORKDIR_HALF_DIRTY=true
|
||||||
else
|
else
|
||||||
|
|
|
@ -764,11 +764,11 @@ prompt_vcs() {
|
||||||
VCS_WORKDIR_DIRTY=false
|
VCS_WORKDIR_DIRTY=false
|
||||||
VCS_WORKDIR_HALF_DIRTY=false
|
VCS_WORKDIR_HALF_DIRTY=false
|
||||||
|
|
||||||
# The vcs segment can have three different states - defaults to ''.
|
# The vcs segment can have three different states - defaults to 'clean'.
|
||||||
local current_state=""
|
local current_state=""
|
||||||
typeset -AH vcs_states
|
typeset -AH vcs_states
|
||||||
vcs_states=(
|
vcs_states=(
|
||||||
'' 'green'
|
'clean' 'green'
|
||||||
'modified' 'red'
|
'modified' 'red'
|
||||||
'untracked' 'yellow'
|
'untracked' 'yellow'
|
||||||
)
|
)
|
||||||
|
@ -824,7 +824,7 @@ prompt_vcs() {
|
||||||
if [[ "$VCS_WORKDIR_HALF_DIRTY" == true ]]; then
|
if [[ "$VCS_WORKDIR_HALF_DIRTY" == true ]]; then
|
||||||
current_state='untracked'
|
current_state='untracked'
|
||||||
else
|
else
|
||||||
current_state=''
|
current_state='clean'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
"$1_prompt_segment" "${0}_${(U)current_state}" "$2" "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier"
|
"$1_prompt_segment" "${0}_${(U)current_state}" "$2" "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier"
|
||||||
|
|
77
test/segments/vcs.spec
Executable file
77
test/segments/vcs.spec
Executable file
|
@ -0,0 +1,77 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
|
||||||
|
|
||||||
|
# Required for shunit2 to run correctly
|
||||||
|
setopt shwordsplit
|
||||||
|
SHUNIT_PARENT=$0
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
export TERM="xterm-256color"
|
||||||
|
# Load Powerlevel9k
|
||||||
|
source powerlevel9k.zsh-theme
|
||||||
|
}
|
||||||
|
|
||||||
|
function testColorOverridingForCleanStateWorks() {
|
||||||
|
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||||
|
POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
|
||||||
|
POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
|
||||||
|
|
||||||
|
FOLDER=/tmp/powerlevel9k-test/vcs-test
|
||||||
|
mkdir -p $FOLDER
|
||||||
|
cd $FOLDER
|
||||||
|
git init 1>/dev/null
|
||||||
|
|
||||||
|
assertEquals "%K{white} %F{cyan} master %k%F{white}%f " "$(build_left_prompt)"
|
||||||
|
|
||||||
|
cd -
|
||||||
|
rm -fr /tmp/powerlevel9k-test
|
||||||
|
|
||||||
|
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||||
|
unset POWERLEVEL9K_VCS_CLEAN_FOREGROUND
|
||||||
|
unset POWERLEVEL9K_VCS_CLEAN_BACKGROUND
|
||||||
|
}
|
||||||
|
|
||||||
|
function testColorOverridingForModifiedStateWorks() {
|
||||||
|
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||||
|
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red'
|
||||||
|
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
|
||||||
|
|
||||||
|
FOLDER=/tmp/powerlevel9k-test/vcs-test
|
||||||
|
mkdir -p $FOLDER
|
||||||
|
cd $FOLDER
|
||||||
|
git init 1>/dev/null
|
||||||
|
touch testfile
|
||||||
|
git add testfile
|
||||||
|
|
||||||
|
assertEquals "%K{yellow} %F{red} master ✚ %k%F{yellow}%f " "$(build_left_prompt)"
|
||||||
|
|
||||||
|
cd -
|
||||||
|
rm -fr /tmp/powerlevel9k-test
|
||||||
|
|
||||||
|
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||||
|
unset POWERLEVEL9K_VCS_MODIFIED_FOREGROUND
|
||||||
|
unset POWERLEVEL9K_VCS_MODIFIED_BACKGROUND
|
||||||
|
}
|
||||||
|
|
||||||
|
function testColorOverridingForUntrackedStateWorks() {
|
||||||
|
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||||
|
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='cyan'
|
||||||
|
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow'
|
||||||
|
|
||||||
|
FOLDER=/tmp/powerlevel9k-test/vcs-test
|
||||||
|
mkdir -p $FOLDER
|
||||||
|
cd $FOLDER
|
||||||
|
git init 1>/dev/null
|
||||||
|
touch testfile
|
||||||
|
|
||||||
|
assertEquals "%K{yellow} %F{cyan} master ? %k%F{yellow}%f " "$(build_left_prompt)"
|
||||||
|
|
||||||
|
cd -
|
||||||
|
rm -fr /tmp/powerlevel9k-test
|
||||||
|
|
||||||
|
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||||
|
unset POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND
|
||||||
|
unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
|
||||||
|
}
|
||||||
|
|
||||||
|
source shunit2/source/2.1/src/shunit2
|
Loading…
Reference in a new issue