mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-22 12:20:07 +00:00
Merge branch 'master' into dritter/test-ratio
This commit is contained in:
commit
41bc89fb72
2 changed files with 83 additions and 63 deletions
12
README.md
12
README.md
|
@ -111,13 +111,21 @@ elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`:
|
||||||
|
|
||||||
#### Test ratio
|
#### Test ratio
|
||||||
|
|
||||||
The `symfony2_tests` and `rspec_tests` segments show both a ratio of code classes
|
The `symfony2_tests` and `rspec_tests` segments show both a ratio of "real" classes
|
||||||
vs test classes. This is just a very simple ratio, and does not show your code
|
vs test classes. This is just a very simple ratio, and does not show your code
|
||||||
coverage or any sophisticated stats. All this does is just to count your files
|
coverage or any sophisticated stats. All this does is just to count your files
|
||||||
and test files and calculate the ratio between them. Not more, but is may give
|
and test files and calculate the ratio between them. Not more, but is may give
|
||||||
a quick overview about the test situation of the project you are dealing with.
|
a quick overview about the test situation of the project you are dealing with.
|
||||||
|
|
||||||
#### The VCS Information Segment
|
#### The 'time' segment
|
||||||
|
|
||||||
|
By default the time is show in 'H:M:S' format. If you want to change it,
|
||||||
|
just set another format in your `~/.zshrc`:
|
||||||
|
|
||||||
|
# Reversed time format
|
||||||
|
POWERLEVEL9K_TIME_FORMAT='%D{%S:%M:%H}'
|
||||||
|
|
||||||
|
#### The 'vcs' Segment
|
||||||
|
|
||||||
By default, the `vcs` segment will provide quite a bit of information. If you
|
By default, the `vcs` segment will provide quite a bit of information. If you
|
||||||
would also like for it to display the current hash / changeset, simply define
|
would also like for it to display the current hash / changeset, simply define
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
# Set your username for the `context` segment:
|
# Set your username for the `context` segment:
|
||||||
# export DEFAULT_USER=<your username>
|
# export DEFAULT_USER=<your username>
|
||||||
#
|
#
|
||||||
|
# Customized the format of the time segment. Example of reverse format:
|
||||||
|
# POWERLEVEL9K_TIME_FORMAT='%D{%S:%M:%H}'
|
||||||
|
#
|
||||||
# Show the hash/changeset string in the `vcs` segment:
|
# Show the hash/changeset string in the `vcs` segment:
|
||||||
# POWERLEVEL9K_SHOW_CHANGESET=true
|
# POWERLEVEL9K_SHOW_CHANGESET=true
|
||||||
# Set the length of the hash/changeset if enabled in the `vcs` segment:
|
# Set the length of the hash/changeset if enabled in the `vcs` segment:
|
||||||
|
@ -157,18 +160,8 @@ right_prompt_segment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# Prompt Components
|
# The 'vcs' Segment and VCS_INFO hooks / helper functions
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# Context: user@hostname (who am I and where am I)
|
|
||||||
# Note that if $DEFAULT_USER is not set, this prompt segment will always print
|
|
||||||
prompt_context() {
|
|
||||||
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
|
||||||
$1_prompt_segment $DEFAULT_COLOR "011" "%(!.%{%F{yellow}%}.)$USER@%m"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# branch/detached head, dirty status
|
|
||||||
prompt_vcs() {
|
prompt_vcs() {
|
||||||
local vcs_prompt="${vcs_info_msg_0_}"
|
local vcs_prompt="${vcs_info_msg_0_}"
|
||||||
|
|
||||||
|
@ -251,31 +244,35 @@ function +vi-vcs-detect-changes() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# Prompt Segments
|
||||||
|
################################################################
|
||||||
|
|
||||||
|
# AWS Profile
|
||||||
|
prompt_aws() {
|
||||||
|
local aws_profile=$AWS_DEFAULT_PROFILE
|
||||||
|
if [[ -n $aws_profile ]];
|
||||||
|
then
|
||||||
|
$1_prompt_segment red white "AWS: $aws_profile"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Context: user@hostname (who am I and where am I)
|
||||||
|
# Note that if $DEFAULT_USER is not set, this prompt segment will always print
|
||||||
|
prompt_context() {
|
||||||
|
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
||||||
|
$1_prompt_segment $DEFAULT_COLOR "011" "%(!.%{%F{yellow}%}.)$USER@%m"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Dir: current working directory
|
# Dir: current working directory
|
||||||
prompt_dir() {
|
prompt_dir() {
|
||||||
$1_prompt_segment blue $DEFAULT_COLOR '%~'
|
$1_prompt_segment blue $DEFAULT_COLOR '%~'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Virtualenv: current working virtualenv
|
# Command number (in local history)
|
||||||
# More information on virtualenv (Python):
|
prompt_history() {
|
||||||
# https://virtualenv.pypa.io/en/latest/
|
$1_prompt_segment "244" $DEFAULT_COLOR '%h'
|
||||||
prompt_virtualenv() {
|
|
||||||
local virtualenv_path="$VIRTUAL_ENV"
|
|
||||||
if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
|
|
||||||
$1_prompt_segment blue $DEFAULT_COLOR "(`basename $virtualenv_path`)"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Left Status: (return code, root status, background jobs)
|
|
||||||
# This creates a status segment for the *left* prompt
|
|
||||||
prompt_status() {
|
|
||||||
local symbols
|
|
||||||
symbols=()
|
|
||||||
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
|
|
||||||
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
|
|
||||||
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
|
|
||||||
|
|
||||||
[[ -n "$symbols" ]] && $1_prompt_segment $DEFAULT_COLOR default "$symbols"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Right Status: (return code, root status, background jobs)
|
# Right Status: (return code, root status, background jobs)
|
||||||
|
@ -299,25 +296,6 @@ prompt_longstatus() {
|
||||||
[[ -n "$symbols" ]] && $1_prompt_segment $bg $DEFAULT_COLOR "$symbols"
|
[[ -n "$symbols" ]] && $1_prompt_segment $bg $DEFAULT_COLOR "$symbols"
|
||||||
}
|
}
|
||||||
|
|
||||||
# System time
|
|
||||||
prompt_time() {
|
|
||||||
$1_prompt_segment $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR '%D{%H:%M:%S} '
|
|
||||||
}
|
|
||||||
|
|
||||||
# Command number (in local history)
|
|
||||||
prompt_history() {
|
|
||||||
$1_prompt_segment "244" $DEFAULT_COLOR '%h'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ruby Version Manager information
|
|
||||||
prompt_rvm() {
|
|
||||||
local rvm_prompt
|
|
||||||
rvm_prompt=`rvm-prompt`
|
|
||||||
if [ "$rvm_prompt" != "" ]; then
|
|
||||||
$1_prompt_segment "240" $DEFAULT_COLOR "$rvm_prompt "
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# rbenv information
|
# rbenv information
|
||||||
prompt_rbenv() {
|
prompt_rbenv() {
|
||||||
if [[ -n "$RBENV_VERSION" ]]; then
|
if [[ -n "$RBENV_VERSION" ]]; then
|
||||||
|
@ -325,15 +303,6 @@ prompt_rbenv() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# AWS Profile
|
|
||||||
prompt_aws() {
|
|
||||||
local aws_profile=$AWS_DEFAULT_PROFILE
|
|
||||||
if [[ -n $aws_profile ]];
|
|
||||||
then
|
|
||||||
$1_prompt_segment red white "AWS: $aws_profile"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# RSpec test ratio
|
# RSpec test ratio
|
||||||
prompt_rspec_stats() {
|
prompt_rspec_stats() {
|
||||||
if [[ (-d app && -d spec) ]]; then
|
if [[ (-d app && -d spec) ]]; then
|
||||||
|
@ -344,6 +313,27 @@ prompt_rspec_stats() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Ruby Version Manager information
|
||||||
|
prompt_rvm() {
|
||||||
|
local rvm_prompt
|
||||||
|
rvm_prompt=`rvm-prompt`
|
||||||
|
if [ "$rvm_prompt" != "" ]; then
|
||||||
|
$1_prompt_segment "240" $DEFAULT_COLOR "$rvm_prompt "
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Left Status: (return code, root status, background jobs)
|
||||||
|
# This creates a status segment for the *left* prompt
|
||||||
|
prompt_status() {
|
||||||
|
local symbols
|
||||||
|
symbols=()
|
||||||
|
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
|
||||||
|
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
|
||||||
|
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
|
||||||
|
|
||||||
|
[[ -n "$symbols" ]] && $1_prompt_segment $DEFAULT_COLOR default "$symbols"
|
||||||
|
}
|
||||||
|
|
||||||
# Symfony2-PHPUnit test ratio
|
# Symfony2-PHPUnit test ratio
|
||||||
prompt_symfony2_tests() {
|
prompt_symfony2_tests() {
|
||||||
if [[ (-d src && -d app && -f app/AppKernel.php) ]]; then
|
if [[ (-d src && -d app && -f app/AppKernel.php) ]]; then
|
||||||
|
@ -369,6 +359,30 @@ build_test_stats() {
|
||||||
[[ ratio -lt 0.5 ]] && $1_prompt_segment red $DEFAULT_COLOR "$headline: $ratio%%"
|
[[ ratio -lt 0.5 ]] && $1_prompt_segment red $DEFAULT_COLOR "$headline: $ratio%%"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# System time
|
||||||
|
prompt_time() {
|
||||||
|
local time_format='%D{%H:%M:%S}'
|
||||||
|
if [[ -n $POWERLEVEL9K_TIME_FORMAT ]]; then
|
||||||
|
time_format=$POWERLEVEL9K_TIME_FORMAT
|
||||||
|
fi
|
||||||
|
|
||||||
|
$1_prompt_segment $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$time_format "
|
||||||
|
}
|
||||||
|
|
||||||
|
# Virtualenv: current working virtualenv
|
||||||
|
# More information on virtualenv (Python):
|
||||||
|
# https://virtualenv.pypa.io/en/latest/
|
||||||
|
prompt_virtualenv() {
|
||||||
|
local virtualenv_path="$VIRTUAL_ENV"
|
||||||
|
if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
|
||||||
|
$1_prompt_segment blue $DEFAULT_COLOR "(`basename $virtualenv_path`)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# Prompt processing and drawing
|
||||||
|
################################################################
|
||||||
|
|
||||||
# Main prompt
|
# Main prompt
|
||||||
build_left_prompt() {
|
build_left_prompt() {
|
||||||
if [[ ${#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS} == 0 ]]; then
|
if [[ ${#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS} == 0 ]]; then
|
||||||
|
@ -395,8 +409,6 @@ build_right_prompt() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################
|
|
||||||
# Create the prompts
|
|
||||||
precmd() {
|
precmd() {
|
||||||
vcs_info
|
vcs_info
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue