Last active
December 11, 2015 18:28
-
-
Save sent-hil/4641437 to your computer and use it in GitHub Desktop.
zsh function to show specs to code ratio in a rails folder, anything over 0.75 is good.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prompt_rspec_stats() { | |
if [[ ((-d app || -d lib) && -d spec) ]]; then | |
if [[ (-d app) ]]; then | |
local app=`wc -l app/**/*.rb | grep -oE "[0-9]+" | tail -n 1` | |
else | |
local app=`wc -l lib/**/*.rb | grep -oE "[0-9]+" | tail -n 1` | |
fi | |
local spec=$((`wc -l spec/**/*.rb | grep -oE "[0-9]+" | tail -n 1`))+0.01 | |
local ratio=`printf "%.2f\n" $((spec/app))` | |
[[ ratio -ge 0.75 ]] && prompt_segment cyan black "$ratio" | |
[[ ratio -ge 0.5 && ratio -lt 0.75 ]] && prompt_segment yellow black "$ratio" | |
[[ ratio -lt 0.5 ]] && prompt_segment red black "$ratio" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice piece of code! Just ported it to
powerlevel9k
-Theme:Powerlevel9k/powerlevel9k#19