diff options
author | Dominik Ritter <dritter03@googlemail.com> | 2015-04-03 16:21:17 +0300 |
---|---|---|
committer | Dominik Ritter <dritter03@googlemail.com> | 2015-04-03 16:21:17 +0300 |
commit | 4d99982e7c6e401dbb4837a3dabf7c39e2e8da08 (patch) | |
tree | 80f995385716b6decb6c4b0651279d62e8166b3e /powerlevel9k.zsh-theme | |
parent | 30aee63f2217261b423c1cf02a86e25c88a9033f (diff) | |
parent | b1d6d3e67d6f6c936c1150ab5f438813bed0a23a (diff) |
Merge branch 'master' into dritter/date_configurable
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rw-r--r-- | powerlevel9k.zsh-theme | 68 |
1 files changed, 64 insertions, 4 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 76b1ac33..f15010c8 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1,5 +1,5 @@ # vim:ft=zsh ts=2 sw=2 sts=2 -# +################################################################ # powerlevel9k Theme # https://github.com/bhilburn/powerlevel9k # @@ -11,10 +11,34 @@ # # In order for this theme to render correctly, you will need a Powerline-patched font: # https://github.com/Lokaltog/powerline-fonts -# +################################################################ -### Segment drawing -# A few utility functions to make it easy and re-usable to draw segmented prompts +################################################################ +# Please see the README file located in the source repository for full docs. +# What follows is a brief list of the settings variables used by this theme. +# You should define these variables in your `~/.zshrc`. +# +# Customize which segments appear in which prompts (below is also the default): +# POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) +# POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time) +# +# Set your Amazon Web Services profile for the `aws` segment: +# export AWS_DEFAULT_PROFILE=<profile_name> +# +# Set your username for the `context` segment: +# export DEFAULT_USER=<your username> +# +# Show the hash/changeset string in the `vcs` segment: +# POWERLEVEL9K_SHOW_CHANGESET=true +# Set the length of the hash/changeset if enabled in the `vcs` segment: +# POWERLEVEL9K_CHANGESET_HASH_LENGTH=6 +# +# Make powerlevel9k a double-lined prompt: +# POWERLEVEL9K_PROMPT_ON_NEWLINE=true +# +# Set the colorscheme: +# POWERLEVEL9K_COLOR_SCHEME='light' +################################################################ # The `CURRENT_BG` variable is used to remember what the last BG color used was # when building the left-hand prompt. Because the RPROMPT is created from @@ -315,6 +339,41 @@ prompt_aws() { fi } +# RSpec test ratio +prompt_rspec_stats() { + if [[ (-d app && -d spec) ]]; then + local code_amount=$(ls -1 app/**/*.rb | wc -l) + local tests_amount=$(ls -1 spec/**/*.rb | wc -l) + + build_test_stats $1 $code_amount $tests_amount "RSpec" + fi +} + +# Symfony2-PHPUnit test ratio +prompt_symfony2_tests() { + if [[ (-d src && -d app && -f app/AppKernel.php) ]]; then + local code_amount=$(ls -1 src/**/*.php | grep -v Tests | wc -l) + local tests_amount=$(ls -1 src/**/*.php | grep Tests | wc -l) + + build_test_stats $1 $code_amount $tests_amount "SF2-Tests" + fi +} + +# Show a ratio of tests vs code +build_test_stats() { + local code_amount=$2 + local tests_amount=$3+0.00001 + local headline=$4 + + # Set float precision to 2 digits: + typeset -F 2 ratio + local ratio=$(( (tests_amount/code_amount) * 100 )) + + [[ ratio -ge 0.75 ]] && $1_prompt_segment cyan $DEFAULT_COLOR "$headline: $ratio%%" + [[ ratio -ge 0.5 && ratio -lt 0.75 ]] && $1_prompt_segment yellow $DEFAULT_COLOR "$headline: $ratio%%" + [[ ratio -lt 0.5 ]] && $1_prompt_segment red $DEFAULT_COLOR "$headline: $ratio%%" +} + # Main prompt build_left_prompt() { if [[ ${#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS} == 0 ]]; then @@ -341,6 +400,7 @@ build_right_prompt() { done } +################################################################ # Create the prompts precmd() { vcs_info |