mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +00:00
Merge branch 'master' into dritter/date_configurable
This commit is contained in:
commit
4d99982e7c
2 changed files with 68 additions and 4 deletions
|
@ -76,8 +76,11 @@ currently available are:
|
|||
* **dir** - Your current working directory.
|
||||
* **history** - The command number for the current line.
|
||||
* **rbenv** - Ruby environment information (if one is active).
|
||||
* **rspec_stats** - Show a ratio of test classes vs code classes for RSpec.
|
||||
* **status** - The return code of the previous command, and status of background jobs.
|
||||
* **symfony2_tests** - Show a ratio of test classes vs code classes for Symfony2.
|
||||
* **time** - System time.
|
||||
* **virtualenv** - Your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/).
|
||||
* **vcs** - Information about this `git` or `hg` repository (if you are in one).
|
||||
|
||||
To specify which segments you want, just add the following variables to your
|
||||
|
@ -130,6 +133,7 @@ The `vcs` segment uses various symbols to tell you the state of your repository:
|
|||
* `●` - There are unstaged changes in your working copy
|
||||
* `✚` - There are staged changes in your working copy
|
||||
* `?` - There are files in your working copy, that are unknown to your repository
|
||||
* `→` - The name of your branch differs from its tracking branch.
|
||||
|
||||
### Styling
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue