1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-19 05:51:57 +00:00

Merge pull request #220 from dritter/rename_vcs_default_state

Rename vcs default state
This commit is contained in:
Ben Hilburn 2016-02-26 09:53:59 -05:00
commit b3fae48893
5 changed files with 92 additions and 4 deletions

View file

@ -24,4 +24,5 @@ script:
- test/segments/dir.spec
- test/segments/rust_version.spec
- test/segments/go_version.spec
- test/segments/vcs.spec

View file

@ -1,5 +1,15 @@
## 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
This segment displays the current Elastic Beanstalk environment.

View file

@ -17,7 +17,7 @@ function +vi-git-untracked() {
fi
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')"
VCS_WORKDIR_HALF_DIRTY=true
else

View file

@ -764,11 +764,11 @@ prompt_vcs() {
VCS_WORKDIR_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=""
typeset -AH vcs_states
vcs_states=(
'' 'green'
'clean' 'green'
'modified' 'red'
'untracked' 'yellow'
)
@ -824,7 +824,7 @@ prompt_vcs() {
if [[ "$VCS_WORKDIR_HALF_DIRTY" == true ]]; then
current_state='untracked'
else
current_state=''
current_state='clean'
fi
fi
"$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
View 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