|
|
@ -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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Dir: current working directory
|
|
|
|
################################################################
|
|
|
|
prompt_dir() {
|
|
|
|
# Prompt Segments
|
|
|
|
$1_prompt_segment blue $DEFAULT_COLOR '%~'
|
|
|
|
################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
# Context: user@hostname (who am I and where am I)
|
|
|
|
# More information on virtualenv (Python):
|
|
|
|
# Note that if $DEFAULT_USER is not set, this prompt segment will always print
|
|
|
|
# https://virtualenv.pypa.io/en/latest/
|
|
|
|
prompt_context() {
|
|
|
|
prompt_virtualenv() {
|
|
|
|
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
|
|
|
local virtualenv_path="$VIRTUAL_ENV"
|
|
|
|
$1_prompt_segment $DEFAULT_COLOR "011" "%(!.%{%F{yellow}%}.)$USER@%m"
|
|
|
|
if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
|
|
|
|
|
|
|
|
$1_prompt_segment blue $DEFAULT_COLOR "(`basename $virtualenv_path`)"
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Left Status: (return code, root status, background jobs)
|
|
|
|
# Dir: current working directory
|
|
|
|
# This creates a status segment for the *left* prompt
|
|
|
|
prompt_dir() {
|
|
|
|
prompt_status() {
|
|
|
|
$1_prompt_segment blue $DEFAULT_COLOR '%~'
|
|
|
|
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"
|
|
|
|
# Command number (in local history)
|
|
|
|
|
|
|
|
prompt_history() {
|
|
|
|
|
|
|
|
$1_prompt_segment "244" $DEFAULT_COLOR '%h'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Right Status: (return code, root status, background jobs)
|
|
|
|
# Right Status: (return code, root status, background jobs)
|
|
|
@ -299,30 +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() {
|
|
|
|
|
|
|
|
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
|
|
|
|
# rbenv information
|
|
|
|
prompt_rbenv() {
|
|
|
|
prompt_rbenv() {
|
|
|
|
if [[ -n "$RBENV_VERSION" ]]; then
|
|
|
|
if [[ -n "$RBENV_VERSION" ]]; then
|
|
|
@ -330,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
|
|
|
@ -349,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
|
|
|
@ -374,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
|
|
|
@ -400,8 +409,6 @@ build_right_prompt() {
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
|
|
|
|
# Create the prompts
|
|
|
|
|
|
|
|
precmd() {
|
|
|
|
precmd() {
|
|
|
|
vcs_info
|
|
|
|
vcs_info
|
|
|
|
|
|
|
|
|
|
|
|