From b738ba900c5cc4cf5fd116e775062172c72466df Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 17 Dec 2015 18:17:06 +0100 Subject: [PATCH 1/4] Added the "visual identifiers" concept to the `ram` segment. --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index df11bb5d..b3927158 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -520,7 +520,7 @@ prompt_ram() { base=K fi - rendition+="$(print_icon 'RAM_ICON') $(printSizeHumanReadable "$ramfree" $base) " + rendition+="$(printSizeHumanReadable "$ramfree" $base) " ;; swap_used) if [[ "$OS" == "OSX" ]]; then @@ -543,7 +543,7 @@ prompt_ram() { esac done - "$1_prompt_segment" "$0" "yellow" "$DEFAULT_COLOR" "${rendition% }" + "$1_prompt_segment" "$0" "yellow" "$DEFAULT_COLOR" "${rendition% }" 'RAM_ICON' } # Node version from NVM From 045f451e4e8bffc4a684bd5abf156193988e1220 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 17 Dec 2015 18:22:34 +0100 Subject: [PATCH 2/4] Added the "visual identifier" concept to the `symfony2_tests` and `rspec_stats` segments. --- powerlevel9k.zsh-theme | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b3927158..e3cb647a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -580,7 +580,7 @@ prompt_rspec_stats() { code_amount=$(ls -1 app/**/*.rb | wc -l) tests_amount=$(ls -1 spec/**/*.rb | wc -l) - build_test_stats "$1" "$0" "$code_amount" "$tests_amount" "RSpec $(print_icon 'TEST_ICON')" + build_test_stats "$1" "$0" "$code_amount" "$tests_amount" "RSpec" 'TEST_ICON' fi } @@ -628,7 +628,7 @@ prompt_symfony2_tests() { code_amount=$(ls -1 src/**/*.php | grep -vc Tests) tests_amount=$(ls -1 src/**/*.php | grep -c Tests) - build_test_stats "$1" "$0" "$code_amount" "$tests_amount" "SF2 $(print_icon 'TEST_ICON')" + build_test_stats "$1" "$0" "$code_amount" "$tests_amount" "SF2" 'TEST_ICON' fi } @@ -651,9 +651,9 @@ build_test_stats() { typeset -F 2 ratio local ratio=$(( (tests_amount/code_amount) * 100 )) - (( ratio >= 75 )) && "$1_prompt_segment" "${2}_GOOD" "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" - (( ratio >= 50 && ratio < 75 )) && "$1_prompt_segment" "$2_AVG" "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" - (( ratio < 50 )) && "$1_prompt_segment" "$2_BAD" "red" "$DEFAULT_COLOR" "$headline: $ratio%%" + (( ratio >= 75 )) && "$1_prompt_segment" "${2}_GOOD" "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio >= 50 && ratio < 75 )) && "$1_prompt_segment" "$2_AVG" "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio < 50 )) && "$1_prompt_segment" "$2_BAD" "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" } # System time From 5cfd800585516ce2251cd4f4cf8f2e1dbadddc70 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 17 Dec 2015 18:24:35 +0100 Subject: [PATCH 3/4] Added the "visual identifier" concept to the `symfony2_version` segment. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index e3cb647a..bf35967a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -637,7 +637,7 @@ prompt_symfony2_version() { if [[ -f app/bootstrap.php.cache ]]; then local symfony2_version symfony2_version=$(grep " VERSION " app/bootstrap.php.cache | sed -e 's/[^.0-9]*//g') - "$1_prompt_segment" "$0" "240" "$DEFAULT_COLOR" "$(print_icon 'SYMFONY_ICON') $symfony2_version" + "$1_prompt_segment" "$0" "240" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' fi } From ac4502ca1fafab54c07d22e4841d8c6c7aeffc95 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Fri, 18 Dec 2015 00:47:37 +0100 Subject: [PATCH 4/4] Added the "visual identifier" concept to the `vcs` segment. --- functions/icons.zsh | 8 ++++---- functions/vcs.zsh | 6 ++++++ powerlevel9k.zsh-theme | 11 +++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 4ba4811e..b8e02efd 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -64,8 +64,8 @@ case $POWERLEVEL9K_MODE in VCS_COMMIT_ICON $'\UE821 ' #  VCS_BRANCH_ICON $'\UE220' #  VCS_REMOTE_BRANCH_ICON ' '$'\UE804 ' #  - VCS_GIT_ICON $'\UE20E ' #  - VCS_HG_ICON $'\UE1C3 ' #  + VCS_GIT_ICON $'\UE20E ' #  + VCS_HG_ICON $'\UE1C3 ' #  ) ;; 'awesome-fontconfig') @@ -111,8 +111,8 @@ case $POWERLEVEL9K_MODE in VCS_COMMIT_ICON $'\UF221 ' #  VCS_BRANCH_ICON $'\UF126' #  VCS_REMOTE_BRANCH_ICON ' '$'\UF204 ' #  - VCS_GIT_ICON $'\UF113 ' #  - VCS_HG_ICON $'\UF0C3 ' #  + VCS_GIT_ICON $'\UF113 ' #  + VCS_HG_ICON $'\UF0C3 ' #  ) ;; *) diff --git a/functions/vcs.zsh b/functions/vcs.zsh index 39d0fdae..49dccc18 100644 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -78,6 +78,12 @@ function +vi-hg-bookmarks() { } function +vi-vcs-detect-changes() { + if [[ "${hook_com[vcs]}" == "git" ]]; then + vcs_visual_identifier='VCS_GIT_ICON' + elif [[ "${hook_com[vcs]}" == "hg" ]]; then + vcs_visual_identifier='VCS_HG_ICON' + fi + if [[ -n "${hook_com[staged]}" ]] || [[ -n "${hook_com[unstaged]}" ]]; then VCS_WORKDIR_DIRTY=true else diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index bf35967a..5e089521 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -696,8 +696,7 @@ prompt_vcs() { zstyle ':vcs_info:*' check-for-changes true VCS_DEFAULT_FORMAT="$VCS_CHANGESET_PREFIX%F{$POWERLEVEL9K_VCS_FOREGROUND}%b%c%u%m%f" - zstyle ':vcs_info:git*:*' formats "%F{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_GIT_ICON')%f$VCS_DEFAULT_FORMAT" - zstyle ':vcs_info:hg*:*' formats "%F{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_HG_ICON')%f$VCS_DEFAULT_FORMAT" + zstyle ':vcs_info:*' formats "$VCS_DEFAULT_FORMAT" zstyle ':vcs_info:*' actionformats "%b %F{red}| %a%f" @@ -724,12 +723,12 @@ prompt_vcs() { if [[ -n "$vcs_prompt" ]]; then if [[ "$VCS_WORKDIR_DIRTY" == true ]]; then - "$1_prompt_segment" "$0_MODIFIED" "yellow" "$DEFAULT_COLOR" + # $vcs_visual_identifier gets set in +vi-vcs-detect-changes in functions/vcs.zsh, + # as we have there access to vcs_info internal hooks. + "$1_prompt_segment" "$0_MODIFIED" "yellow" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" else - "$1_prompt_segment" "$0" "green" "$DEFAULT_COLOR" + "$1_prompt_segment" "$0" "green" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" fi - - echo -n "$vcs_prompt " fi }