aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hilburn <ben.hilburn@ettus.com>2015-04-03 19:15:16 +0300
committerBen Hilburn <ben.hilburn@ettus.com>2015-04-03 19:15:16 +0300
commit13273fccd66709db62f93c772c9e052d398dac88 (patch)
treef079fdd649ea33955617f30d8257ee7f1d026192
parent56dc536f6c143ca892c1922f5be132c13351c4f2 (diff)
Adding time format string doc to theme file. Making segments alphabetical.
-rw-r--r--README.md2
-rw-r--r--powerlevel9k.zsh-theme137
2 files changed, 73 insertions, 66 deletions
diff --git a/README.md b/README.md
index dd0e06f4..880904f9 100644
--- a/README.md
+++ b/README.md
@@ -117,7 +117,7 @@ just set another format in your `~/.zshrc`:
# Reversed time format
POWERLEVEL9K_TIME_FORMAT='%D{%S:%M:%H}'
-#### The VCS Information Segment
+#### The 'vcs' Segment
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
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 27c547f8..1662d58d 100644
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -28,6 +28,9 @@
# Set your username for the `context` segment:
# 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:
# POWERLEVEL9K_SHOW_CHANGESET=true
# 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() {
local vcs_prompt="${vcs_info_msg_0_}"
@@ -251,31 +244,35 @@ function +vi-vcs-detect-changes() {
fi
}
-# Dir: current working directory
-prompt_dir() {
- $1_prompt_segment blue $DEFAULT_COLOR '%~'
+################################################################
+# 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
}
-# 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`)"
+# 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
}
-# 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}%}⚙"
+# Dir: current working directory
+prompt_dir() {
+ $1_prompt_segment blue $DEFAULT_COLOR '%~'
+}
- [[ -n "$symbols" ]] && $1_prompt_segment $DEFAULT_COLOR default "$symbols"
+# Command number (in local history)
+prompt_history() {
+ $1_prompt_segment "244" $DEFAULT_COLOR '%h'
}
# Right Status: (return code, root status, background jobs)
@@ -299,30 +296,6 @@ prompt_longstatus() {
[[ -n "$symbols" ]] && $1_prompt_segment $bg $DEFAULT_COLOR "$symbols"
}
-# 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 "
-}
-
-# 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
prompt_rbenv() {
if [[ -n "$RBENV_VERSION" ]]; then
@@ -330,15 +303,6 @@ prompt_rbenv() {
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
prompt_rspec_stats() {
if [[ (-d app && -d spec) ]]; then
@@ -349,6 +313,27 @@ prompt_rspec_stats() {
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
prompt_symfony2_tests() {
if [[ (-d src && -d app && -f app/AppKernel.php) ]]; then
@@ -374,6 +359,30 @@ build_test_stats() {
[[ 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
build_left_prompt() {
if [[ ${#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS} == 0 ]]; then
@@ -400,8 +409,6 @@ build_right_prompt() {
done
}
-################################################################
-# Create the prompts
precmd() {
vcs_info