diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2016-02-26 17:53:59 +0300 |
---|---|---|
committer | Ben Hilburn <bhilburn@gmail.com> | 2016-02-26 17:53:59 +0300 |
commit | b3fae488934fef856805a9012f08fb4146764aa6 (patch) | |
tree | 5448ff41748b48091ae1fd25df2916297f66eb06 | |
parent | 5d31763a8eab213cdcf59d76283b34e75fd93d4d (diff) | |
parent | cb5d33affb4fb223ec29f6dfb89ff8b0bb6e9133 (diff) |
Merge pull request #220 from dritter/rename_vcs_default_state
Rename vcs default state
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | CHANGELOG.md | 10 | ||||
-rw-r--r-- | functions/vcs.zsh | 2 | ||||
-rwxr-xr-x | powerlevel9k.zsh-theme | 6 | ||||
-rwxr-xr-x | test/segments/vcs.spec | 77 |
5 files changed, 92 insertions, 4 deletions
diff --git a/.travis.yml b/.travis.yml index 71aff690..4f2c7a39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,5 @@ script: - test/segments/dir.spec - test/segments/rust_version.spec - test/segments/go_version.spec + - test/segments/vcs.spec diff --git a/CHANGELOG.md b/CHANGELOG.md index 728f3578..557f977b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/functions/vcs.zsh b/functions/vcs.zsh index 9baccd24..9d3883ca 100644 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -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 diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 38651fe9..d573f6f9 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -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" diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec new file mode 100755 index 00000000..862067b7 --- /dev/null +++ b/test/segments/vcs.spec @@ -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 |