Merge pull request #815 from edubxb/powerline-themes-refactor

Refactor of all powerline themes
pull/816/head
Nils Winkler 2016-10-30 16:22:15 +01:00 committed by GitHub
commit 8a2b6bdc54
12 changed files with 539 additions and 507 deletions

View File

@ -8,6 +8,7 @@ A colorful multiline theme, where the first line shows information about your sh
* Current path
* Current username and hostname
* Current time
* An indicator when connected by SSH
* An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this)
* An indicator when the current shell is inside the Vim editor

View File

@ -0,0 +1,62 @@
. "$BASH_IT/themes/powerline/powerline.base.bash"
function __powerline_last_status_prompt {
[[ "$1" -ne 0 ]] && echo "$(set_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${1} ${normal}"
}
function __powerline_right_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
IFS="${OLD_IFS}"
local separator_char="${POWERLINE_RIGHT_SEPARATOR}"
local padding=2
local separator_color=""
if [[ "${SEGMENTS_AT_RIGHT}" -eq 0 ]]; then
separator_color="$(set_color ${params[1]} -)"
else
separator_color="$(set_color ${params[1]} ${LAST_SEGMENT_COLOR})"
(( padding += 1 ))
fi
RIGHT_PROMPT+="${separator_color}${separator_char}${normal}$(set_color - ${params[1]}) ${params[0]} ${normal}$(set_color - ${COLOR})${normal}"
RIGHT_PROMPT_LENGTH=$(( ${#params[0]} + RIGHT_PROMPT_LENGTH + padding ))
LAST_SEGMENT_COLOR="${params[1]}"
(( SEGMENTS_AT_RIGHT += 1 ))
}
function __powerline_prompt_command {
local last_status="$?" ## always the first
local separator_char="${POWERLINE_LEFT_SEPARATOR}"
local move_cursor_rightmost='\033[500C'
LEFT_PROMPT=""
RIGHT_PROMPT=""
RIGHT_PROMPT_LENGTH=0
SEGMENTS_AT_LEFT=0
SEGMENTS_AT_RIGHT=0
LAST_SEGMENT_COLOR=""
## left prompt ##
for segment in $POWERLINE_LEFT_PROMPT; do
local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
done
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}"
## right prompt ##
if [[ -n "${POWERLINE_RIGHT_PROMPT}" ]]; then
LEFT_PROMPT+="${move_cursor_rightmost}"
for segment in $POWERLINE_RIGHT_PROMPT; do
local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_right_segment "${info}"
done
LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D"
fi
PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n$(__powerline_last_status_prompt ${last_status})${PROMPT_CHAR} "
## cleanup ##
unset LAST_SEGMENT_COLOR \
LEFT_PROMPT RIGHT_PROMPT RIGHT_PROMPT_LENGTH \
SEGMENTS_AT_LEFT SEGMENTS_AT_RIGHT
}

View File

@ -1,5 +1,11 @@
#!/usr/bin/env bash
. "$BASH_IT/themes/powerline-multiline/powerline-multiline.base.bash"
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
POWERLINE_RIGHT_SEPARATOR=${POWERLINE_RIGHT_SEPARATOR:=""}
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "}
USER_INFO_THEME_PROMPT_COLOR=32
USER_INFO_THEME_PROMPT_COLOR_SUDO=202
@ -10,11 +16,8 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35
SCM_NONE_CHAR=""
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN_COLOR=25
SCM_THEME_PROMPT_DIRTY_COLOR=88
SCM_THEME_PROMPT_STAGED_COLOR=30
@ -25,9 +28,8 @@ RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=161
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="r"}
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="r "}
CWD_THEME_PROMPT_COLOR=240
@ -48,196 +50,4 @@ IN_VIM_THEME_PROMPT_TEXT="vim"
POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby cwd"}
POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"}
function set_rgb_color {
if [[ "${1}" != "-" ]]; then
fg="38;5;${1}"
fi
if [[ "${2}" != "-" ]]; then
bg="48;5;${2}"
[[ -n "${fg}" ]] && bg=";${bg}"
fi
echo -e "\[\033[${fg}${bg}m\]"
}
function __powerline_user_info_prompt {
local user_info=""
local color=${USER_INFO_THEME_PROMPT_COLOR}
if sudo -n uptime 2>&1 | grep -q "load"; then
color=${USER_INFO_THEME_PROMPT_COLOR_SUDO}
fi
case "${POWERLINE_PROMPT_USER_INFO_MODE}" in
"sudo")
if [[ "${color}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then
user_info="!"
fi
;;
*)
if [[ -n "${SSH_CLIENT}" ]]; then
user_info="${USER_INFO_SSH_CHAR}${USER}@${HOSTNAME}"
else
user_info="${USER}"
fi
;;
esac
[[ -n "${user_info}" ]] && echo "${user_info}|${color}"
}
function __powerline_ruby_prompt {
local ruby_version=""
if command_exists rvm; then
ruby_version="$(rvm_version_prompt)"
elif command_exists rbenv; then
ruby_version=$(rbenv_version_prompt)
fi
[[ -n "${ruby_version}" ]] && echo "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}"
}
function __powerline_python_venv_prompt {
local python_venv=""
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
python_venv="${CONDA_DEFAULT_ENV}"
PYTHON_VENV_CHAR=${CONDA_PYTHON_VENV_CHAR}
elif [[ -n "${VIRTUAL_ENV}" ]]; then
python_venv=$(basename "${VIRTUAL_ENV}")
fi
[[ -n "${python_venv}" ]] && echo "${PYTHON_VENV_CHAR}${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}"
}
function __powerline_scm_prompt {
local color=""
local scm_prompt=""
scm_prompt_vars
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
if [[ "${SCM_DIRTY}" -eq 3 ]]; then
color=${SCM_THEME_PROMPT_STAGED_COLOR}
elif [[ "${SCM_DIRTY}" -eq 2 ]]; then
color=${SCM_THEME_PROMPT_UNSTAGED_COLOR}
elif [[ "${SCM_DIRTY}" -eq 1 ]]; then
color=${SCM_THEME_PROMPT_DIRTY_COLOR}
else
color=${SCM_THEME_PROMPT_CLEAN_COLOR}
fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi
echo "${scm_prompt}${scm}|${color}"
fi
}
function __powerline_cwd_prompt {
echo "$(pwd | sed "s|^${HOME}|~|")|${CWD_THEME_PROMPT_COLOR}"
}
function __powerline_clock_prompt {
echo "$(date +"${THEME_CLOCK_FORMAT}")|${CLOCK_THEME_PROMPT_COLOR}"
}
function __powerline_battery_prompt {
local color=""
local battery_status="$(battery_percentage 2> /dev/null)"
if [[ -z "${battery_status}" ]] || [[ "${battery_status}" = "-1" ]] || [[ "${battery_status}" = "no" ]]; then
true
else
if [[ "$((10#${battery_status}))" -le 5 ]]; then
color="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}"
elif [[ "$((10#${battery_status}))" -le 25 ]]; then
color="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}"
else
color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}"
fi
ac_adapter_connected && battery_status="${BATTERY_AC_CHAR}${battery_status}"
echo "${battery_status}%|${color}"
fi
}
function __powerline_in_vim_prompt {
if [ -n "$VIMRUNTIME" ]; then
echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}"
fi
}
function __powerline_last_status_prompt {
[[ "$1" -ne 0 ]] && echo "$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${1} ${normal}"
}
function __powerline_left_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
IFS="${OLD_IFS}"
local separator_char=""
local separator=""
if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then
separator="$(set_rgb_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}${normal}"
fi
LEFT_PROMPT+="${separator}$(set_rgb_color - ${params[1]}) ${params[0]} ${normal}"
LAST_SEGMENT_COLOR=${params[1]}
(( SEGMENTS_AT_LEFT += 1 ))
}
function __powerline_right_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
IFS="${OLD_IFS}"
local separator_char=""
local padding=2
local separator_color=""
if [[ "${SEGMENTS_AT_RIGHT}" -eq 0 ]]; then
separator_color="$(set_rgb_color ${params[1]} -)"
else
separator_color="$(set_rgb_color ${params[1]} ${LAST_SEGMENT_COLOR})"
(( padding += 1 ))
fi
RIGHT_PROMPT+="${separator_color}${separator_char}${normal}$(set_rgb_color - ${params[1]}) ${params[0]} ${normal}$(set_rgb_color - ${COLOR})${normal}"
RIGHT_PROMPT_LENGTH=$(( ${#params[0]} + RIGHT_PROMPT_LENGTH + padding ))
LAST_SEGMENT_COLOR="${params[1]}"
(( SEGMENTS_AT_RIGHT += 1 ))
}
function __powerline_prompt_command {
local last_status="$?" ## always the first
local separator_char=""
local move_cursor_rightmost='\033[500C'
LEFT_PROMPT=""
RIGHT_PROMPT=""
RIGHT_PROMPT_LENGTH=0
SEGMENTS_AT_LEFT=0
SEGMENTS_AT_RIGHT=0
LAST_SEGMENT_COLOR=""
## left prompt ##
for segment in $POWERLINE_LEFT_PROMPT; do
local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
done
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_rgb_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}"
## right prompt ##
if [[ -n "${POWERLINE_RIGHT_PROMPT}" ]]; then
LEFT_PROMPT+="${move_cursor_rightmost}"
for segment in $POWERLINE_RIGHT_PROMPT; do
local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_right_segment "${info}"
done
LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D"
fi
PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n$(__powerline_last_status_prompt ${last_status})${PROMPT_CHAR} "
## cleanup ##
unset LAST_SEGMENT_COLOR \
LEFT_PROMPT RIGHT_PROMPT RIGHT_PROMPT_LENGTH \
SEGMENTS_AT_LEFT SEGMENTS_AT_RIGHT
}
safe_append_prompt_command __powerline_prompt_command

View File

@ -0,0 +1,58 @@
# Powerline Theme
A colorful theme, where shows a lot information about your shell session.
**IMPORTANT:** This theme requires that [a font with the Powerline symbols](https://github.com/powerline/fonts) needs to be used in your terminal emulator, otherwise the prompt won't be displayed correctly, i.e. some of the additional icons and characters will be missing. Please follow your operating system's instructions to install one of the fonts from the above link and select it in your terminal emulator.
## Provided Information
* Current path
* Current username and hostname
* Current time
* An indicator when connected by SSH
* An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this)
* An indicator when the current shell is inside the Vim editor
* Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin))
* SCM Repository status (e.g. Git, SVN)
* The current Python environment (Virtualenv, venv, and Conda are supported) in use
* The current Ruby environment (RVM) in use
* Last command exit code (only shown when the exit code is greater than 0)
## Configuration
This theme is pretty configurable, all the configuration is done by setting environment variables.
### User Information
By default, the username and hostname are shown, but you can change this behavior by setting the value of the following variable:
POWERLINE_PROMPT_USER_INFO_MODE="sudo"
For now, the only supported value is `sudo`, which hides the username and hostname, and shows an indicator when `sudo` has the credentials cached. Other values have no effect at this time.
### Clock Format
You can change the format using the following variable:
THEME_CLOCK_FORMAT="%H:%M:%S"
The time/date is printed by the `date` command, so refer to its man page to change the format.
### Segment Order
The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
* battery
* clock
* cwd
* in_vim
* python_venv
* rvm
* scm
* user_info
A variables can be defined to set the order of the prompt segments:
POWERLINE_PROMPT="user_info scm python_venv rvm cwd"
The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the variable.

View File

@ -0,0 +1,15 @@
. "$BASH_IT/themes/powerline/powerline.base.bash"
function __powerline_left_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
IFS="${OLD_IFS}"
local separator_char=""
local separator=""
if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then
separator="${separator_char}"
fi
LEFT_PROMPT+="${separator}$(set_color ${params[1]} -) ${params[0]} ${normal}"
(( SEGMENTS_AT_LEFT += 1 ))
}

View File

@ -1,110 +1,52 @@
#!/usr/bin/env bash
THEME_PROMPT_SEPARATOR=""
. "$BASH_IT/themes/powerline-naked/powerline-naked.base.bash"
SHELL_SSH_CHAR=" "
SHELL_THEME_PROMPT_COLOR=32
SHELL_SSH_THEME_PROMPT_COLOR=208
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
VIRTUALENV_CHAR="ⓔ "
VIRTUALENV_THEME_PROMPT_COLOR=35
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "}
USER_INFO_THEME_PROMPT_COLOR=240
USER_INFO_THEME_PROMPT_COLOR_SUDO=202
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="p "}
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="c "}
PYTHON_VENV_THEME_PROMPT_COLOR=35
SCM_NONE_CHAR=""
SCM_GIT_CHAR=" "
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_COLOR=238
SCM_THEME_PROMPT_CLEAN_COLOR=231
SCM_THEME_PROMPT_DIRTY_COLOR=196
SCM_THEME_PROMPT_STAGED_COLOR=220
SCM_THEME_PROMPT_UNSTAGED_COLOR=166
SCM_THEME_PROMPT_CLEAN_COLOR=25
SCM_THEME_PROMPT_DIRTY_COLOR=88
SCM_THEME_PROMPT_STAGED_COLOR=30
SCM_THEME_PROMPT_UNSTAGED_COLOR=92
SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}
CWD_THEME_PROMPT_COLOR=240
RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=161
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="r "}
CWD_THEME_PROMPT_COLOR=254
LAST_STATUS_THEME_PROMPT_COLOR=124
function set_rgb_color {
if [[ "${1}" != "-" ]]; then
fg="38;5;${1}"
fi
if [[ "${2}" != "-" ]]; then
bg="48;5;${2}"
[[ -n "${fg}" ]] && bg=";${bg}"
fi
echo -e "\[\033[${fg}${bg}m\]"
}
CLOCK_THEME_PROMPT_COLOR=240
function powerline_shell_prompt {
if [[ -n "${SSH_CLIENT}" ]]; then
SHELL_PROMPT="${bold_white} ${SHELL_SSH_CHAR}\u@\h ${normal}"
else
SHELL_PROMPT="${bold_white} \u ${normal}"
fi
}
BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"}
BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160
function powerline_virtualenv_prompt {
local environ=""
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
environ="conda: $CONDA_DEFAULT_ENV"
elif [[ -n "$VIRTUAL_ENV" ]]; then
environ=$(basename "$VIRTUAL_ENV")
fi
IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim"
if [[ -n "$environ" ]]; then
VIRTUALENV_PROMPT="${THEME_PROMPT_SEPARATOR}$(set_rgb_color ${VIRTUALENV_THEME_PROMPT_COLOR} -) ${VIRTUALENV_CHAR}$environ ${normal}"
else
VIRTUALENV_PROMPT=""
fi
}
function powerline_scm_prompt {
scm_prompt_vars
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
if [[ "${SCM_DIRTY}" -eq 3 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_STAGED_COLOR} -)"
elif [[ "${SCM_DIRTY}" -eq 2 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_UNSTAGED_COLOR} -)"
elif [[ "${SCM_DIRTY}" -eq 1 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} -)"
else
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} -)"
fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE} "
fi
SCM_PROMPT="${THEME_PROMPT_SEPARATOR}${SCM_PROMPT}${normal}"
else
SCM_PROMPT=""
fi
}
function powerline_cwd_prompt {
CWD_PROMPT="${THEME_PROMPT_SEPARATOR} \w "
}
function powerline_last_status_prompt {
if [[ "$1" -eq 0 ]]; then
LAST_STATUS_PROMPT="${THEME_PROMPT_SEPARATOR}"
else
LAST_STATUS_PROMPT="${THEME_PROMPT_SEPARATOR}$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${LAST_STATUS} ${normal}${THEME_PROMPT_SEPARATOR}"
fi
}
function powerline_prompt_command() {
local LAST_STATUS="$?"
powerline_shell_prompt
powerline_virtualenv_prompt
powerline_scm_prompt
powerline_cwd_prompt
powerline_last_status_prompt LAST_STATUS
PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} "
}
safe_append_prompt_command powerline_prompt_command
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
safe_append_prompt_command __powerline_prompt_command

View File

@ -0,0 +1,56 @@
# Powerline Theme
A colorful theme, where shows a lot information about your shell session.
## Provided Information
* Current path
* Current username and hostname
* Current time
* An indicator when connected by SSH
* An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this)
* An indicator when the current shell is inside the Vim editor
* Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin))
* SCM Repository status (e.g. Git, SVN)
* The current Python environment (Virtualenv, venv, and Conda are supported) in use
* The current Ruby environment (RVM) in use
* Last command exit code (only shown when the exit code is greater than 0)
## Configuration
This theme is pretty configurable, all the configuration is done by setting environment variables.
### User Information
By default, the username and hostname are shown, but you can change this behavior by setting the value of the following variable:
POWERLINE_PROMPT_USER_INFO_MODE="sudo"
For now, the only supported value is `sudo`, which hides the username and hostname, and shows an indicator when `sudo` has the credentials cached. Other values have no effect at this time.
### Clock Format
You can change the format using the following variable:
THEME_CLOCK_FORMAT="%H:%M:%S"
The time/date is printed by the `date` command, so refer to its man page to change the format.
### Segment Order
The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
* battery
* clock
* cwd
* in_vim
* python_venv
* rvm
* scm
* user_info
A variables can be defined to set the order of the prompt segments:
POWERLINE_PROMPT="user_info scm python_venv rvm cwd"
The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the variable.

View File

@ -0,0 +1,29 @@
. "$BASH_IT/themes/powerline/powerline.base.bash"
function __powerline_left_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
IFS="${OLD_IFS}"
LEFT_PROMPT+="${separator}$(set_color - ${params[1]}) ${params[0]} ${normal}"
LAST_SEGMENT_COLOR=${params[1]}
}
function __powerline_prompt_command {
local last_status="$?" ## always the first
LEFT_PROMPT=""
## left prompt ##
for segment in $POWERLINE_PROMPT; do
local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
done
[[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status})
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -) ${normal}"
PS1="${LEFT_PROMPT} "
## cleanup ##
unset LEFT_PROMPT
}

View File

@ -1,124 +1,49 @@
#!/usr/bin/env bash
SHELL_SSH_CHAR="⌁ "
SHELL_THEME_PROMPT_COLOR=32
SHELL_SSH_THEME_PROMPT_COLOR=208
. "$BASH_IT/themes/powerline-plain/powerline-plain.base.bash"
VIRTUALENV_CHAR="ⓔ "
VIRTUALENV_THEME_PROMPT_COLOR=25
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:="⌁ "}
USER_INFO_THEME_PROMPT_COLOR=32
USER_INFO_THEME_PROMPT_COLOR_SUDO=202
GEMSET_CHAR="ⓔ "
GEMSET_THEME_PROMPT_COLOR=25
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="ⓔ "}
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="ⓔ "}
PYTHON_VENV_THEME_PROMPT_COLOR=35
SCM_NONE_CHAR=""
SCM_GIT_CHAR="⎇ "
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:="⎇ "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN_COLOR=25
SCM_THEME_PROMPT_DIRTY_COLOR=88
SCM_THEME_PROMPT_STAGED_COLOR=30
SCM_THEME_PROMPT_UNSTAGED_COLOR=92
SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}
SCM_THEME_PROMPT_COLOR=238
SCM_THEME_PROMPT_CLEAN_COLOR=231
SCM_THEME_PROMPT_DIRTY_COLOR=196
SCM_THEME_PROMPT_STAGED_COLOR=220
SCM_THEME_PROMPT_UNSTAGED_COLOR=166
RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=161
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="ⓔ "}
CWD_THEME_PROMPT_COLOR=240
LAST_STATUS_THEME_PROMPT_COLOR=52
function set_rgb_color {
if [[ "${1}" != "-" ]]; then
fg="38;5;${1}"
fi
if [[ "${2}" != "-" ]]; then
bg="48;5;${2}"
[[ -n "${fg}" ]] && bg=";${bg}"
fi
echo -e "\[\033[${fg}${bg}m\]"
}
CLOCK_THEME_PROMPT_COLOR=240
function powerline_shell_prompt {
if [[ -n "${SSH_CLIENT}" ]]; then
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_SSH_THEME_PROMPT_COLOR}) ${SHELL_SSH_CHAR}\u@\h ${normal}"
else
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_THEME_PROMPT_COLOR}) \u ${normal}"
fi
}
BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="+ "}
BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160
function powerline_virtualenv_prompt {
local environ=""
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
environ="conda: $CONDA_DEFAULT_ENV"
elif [[ -n "$VIRTUAL_ENV" ]]; then
environ=$(basename "$VIRTUAL_ENV")
fi
IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim"
if [[ -n "$environ" ]]; then
VIRTUALENV_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$environ ${normal}"
LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR}
else
VIRTUALENV_PROMPT=""
fi
}
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
function powerline_gemset_prompt {
local gemset=$(rvm-prompt 2>/dev/null)
if [[ -n "$gemset" ]]; then
GEMSET_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${GEMSET_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${GEMSET_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$gemset ${normal}"
LAST_THEME_COLOR=${GEMSET_THEME_PROMPT_COLOR}
else
GEMSET_PROMPT=""
fi
}
function powerline_scm_prompt {
scm_prompt_vars
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
if [[ "${SCM_DIRTY}" -eq 3 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_STAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
elif [[ "${SCM_DIRTY}" -eq 2 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_UNSTAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
elif [[ "${SCM_DIRTY}" -eq 1 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})"
else
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})"
fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE} "
fi
SCM_PROMPT="${SCM_PROMPT}${normal}"
else
SCM_PROMPT=""
fi
}
function powerline_cwd_prompt {
CWD_PROMPT="${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}"
}
function powerline_last_status_prompt {
if [[ "$1" -eq 0 ]]; then
LAST_STATUS_PROMPT=""
else
LAST_STATUS_PROMPT="$(set_rgb_color - ${LAST_STATUS_THEME_PROMPT_COLOR}) ${LAST_STATUS} ${normal}$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
fi
}
function powerline_prompt_command() {
local LAST_STATUS="$?"
powerline_shell_prompt
powerline_virtualenv_prompt
powerline_gemset_prompt
powerline_scm_prompt
powerline_cwd_prompt
powerline_last_status_prompt LAST_STATUS
PS1="${SHELL_PROMPT}${GEMSET_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} "
}
safe_append_prompt_command powerline_prompt_command
safe_append_prompt_command __powerline_prompt_command

View File

@ -0,0 +1,58 @@
# Powerline Theme
A colorful theme, where shows a lot information about your shell session.
**IMPORTANT:** This theme requires that [a font with the Powerline symbols](https://github.com/powerline/fonts) needs to be used in your terminal emulator, otherwise the prompt won't be displayed correctly, i.e. some of the additional icons and characters will be missing. Please follow your operating system's instructions to install one of the fonts from the above link and select it in your terminal emulator.
## Provided Information
* Current path
* Current username and hostname
* Current time
* An indicator when connected by SSH
* An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this)
* An indicator when the current shell is inside the Vim editor
* Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin))
* SCM Repository status (e.g. Git, SVN)
* The current Python environment (Virtualenv, venv, and Conda are supported) in use
* The current Ruby environment (RVM) in use
* Last command exit code (only shown when the exit code is greater than 0)
## Configuration
This theme is pretty configurable, all the configuration is done by setting environment variables.
### User Information
By default, the username and hostname are shown, but you can change this behavior by setting the value of the following variable:
POWERLINE_PROMPT_USER_INFO_MODE="sudo"
For now, the only supported value is `sudo`, which hides the username and hostname, and shows an indicator when `sudo` has the credentials cached. Other values have no effect at this time.
### Clock Format
You can change the format using the following variable:
THEME_CLOCK_FORMAT="%H:%M:%S"
The time/date is printed by the `date` command, so refer to its man page to change the format.
### Segment Order
The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
* battery
* clock
* cwd
* in_vim
* python_venv
* rvm
* scm
* user_info
A variables can be defined to set the order of the prompt segments:
POWERLINE_PROMPT="user_info scm python_venv rvm cwd"
The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the variable.

View File

@ -0,0 +1,158 @@
function set_color {
if [[ "${1}" != "-" ]]; then
fg="38;5;${1}"
fi
if [[ "${2}" != "-" ]]; then
bg="48;5;${2}"
[[ -n "${fg}" ]] && bg=";${bg}"
fi
echo -e "\[\033[${fg}${bg}m\]"
}
function __powerline_user_info_prompt {
local user_info=""
local color=${USER_INFO_THEME_PROMPT_COLOR}
if sudo -n uptime 2>&1 | grep -q "load"; then
color=${USER_INFO_THEME_PROMPT_COLOR_SUDO}
fi
case "${POWERLINE_PROMPT_USER_INFO_MODE}" in
"sudo")
if [[ "${color}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then
user_info="!"
fi
;;
*)
if [[ -n "${SSH_CLIENT}" ]]; then
user_info="${USER_INFO_SSH_CHAR}${USER}@${HOSTNAME}"
else
user_info="${USER}"
fi
;;
esac
[[ -n "${user_info}" ]] && echo "${user_info}|${color}"
}
function __powerline_ruby_prompt {
local ruby_version=""
if command_exists rvm; then
ruby_version="$(rvm_version_prompt)"
elif command_exists rbenv; then
ruby_version=$(rbenv_version_prompt)
fi
[[ -n "${ruby_version}" ]] && echo "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}"
}
function __powerline_python_venv_prompt {
local python_venv=""
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
python_venv="${CONDA_DEFAULT_ENV}"
PYTHON_VENV_CHAR=${CONDA_PYTHON_VENV_CHAR}
elif [[ -n "${VIRTUAL_ENV}" ]]; then
python_venv=$(basename "${VIRTUAL_ENV}")
fi
[[ -n "${python_venv}" ]] && echo "${PYTHON_VENV_CHAR}${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}"
}
function __powerline_scm_prompt {
local color=""
local scm_prompt=""
scm_prompt_vars
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
if [[ "${SCM_DIRTY}" -eq 3 ]]; then
color=${SCM_THEME_PROMPT_STAGED_COLOR}
elif [[ "${SCM_DIRTY}" -eq 2 ]]; then
color=${SCM_THEME_PROMPT_UNSTAGED_COLOR}
elif [[ "${SCM_DIRTY}" -eq 1 ]]; then
color=${SCM_THEME_PROMPT_DIRTY_COLOR}
else
color=${SCM_THEME_PROMPT_CLEAN_COLOR}
fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi
echo "${scm_prompt}${scm}|${color}"
fi
}
function __powerline_cwd_prompt {
echo "$(pwd | sed "s|^${HOME}|~|")|${CWD_THEME_PROMPT_COLOR}"
}
function __powerline_clock_prompt {
echo "$(date +"${THEME_CLOCK_FORMAT}")|${CLOCK_THEME_PROMPT_COLOR}"
}
function __powerline_battery_prompt {
local color=""
local battery_status="$(battery_percentage 2> /dev/null)"
if [[ -z "${battery_status}" ]] || [[ "${battery_status}" = "-1" ]] || [[ "${battery_status}" = "no" ]]; then
true
else
if [[ "$((10#${battery_status}))" -le 5 ]]; then
color="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}"
elif [[ "$((10#${battery_status}))" -le 25 ]]; then
color="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}"
else
color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}"
fi
ac_adapter_connected && battery_status="${BATTERY_AC_CHAR}${battery_status}"
echo "${battery_status}%|${color}"
fi
}
function __powerline_in_vim_prompt {
if [ -n "$VIMRUNTIME" ]; then
echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}"
fi
}
function __powerline_left_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
IFS="${OLD_IFS}"
local separator_char="${POWERLINE_LEFT_SEPARATOR}"
local separator=""
if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then
separator="$(set_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}"
fi
LEFT_PROMPT+="${separator}$(set_color - ${params[1]}) ${params[0]} ${normal}"
LAST_SEGMENT_COLOR=${params[1]}
(( SEGMENTS_AT_LEFT += 1 ))
}
function __powerline_last_status_prompt {
[[ "$1" -ne 0 ]] && echo "${1}|${LAST_STATUS_THEME_PROMPT_COLOR}"
}
function __powerline_prompt_command {
local last_status="$?" ## always the first
local separator_char="${POWERLINE_PROMPT_CHAR}"
LEFT_PROMPT=""
SEGMENTS_AT_LEFT=0
LAST_SEGMENT_COLOR=""
## left prompt ##
for segment in $POWERLINE_PROMPT; do
local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
done
[[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status})
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}"
PS1="${LEFT_PROMPT} "
## cleanup ##
unset LAST_SEGMENT_COLOR \
LEFT_PROMPT \
SEGMENTS_AT_LEFT
}

View File

@ -1,133 +1,51 @@
#!/usr/bin/env bash
THEME_PROMPT_SEPARATOR=""
. "$BASH_IT/themes/powerline/powerline.base.bash"
SHELL_SSH_CHAR=" "
SHELL_THEME_PROMPT_COLOR=32
SHELL_THEME_PROMPT_COLOR_SUDO=202
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
VIRTUALENV_CHAR="ⓔ "
VIRTUALENV_THEME_PROMPT_COLOR=35
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "}
USER_INFO_THEME_PROMPT_COLOR=32
USER_INFO_THEME_PROMPT_COLOR_SUDO=202
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="p "}
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="c "}
PYTHON_VENV_THEME_PROMPT_COLOR=35
SCM_NONE_CHAR=""
SCM_GIT_CHAR=" "
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN_COLOR=25
SCM_THEME_PROMPT_DIRTY_COLOR=88
SCM_THEME_PROMPT_STAGED_COLOR=30
SCM_THEME_PROMPT_UNSTAGED_COLOR=92
SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}
SCM_THEME_PROMPT_COLOR=238
SCM_THEME_PROMPT_CLEAN_COLOR=231
SCM_THEME_PROMPT_DIRTY_COLOR=196
SCM_THEME_PROMPT_STAGED_COLOR=220
SCM_THEME_PROMPT_UNSTAGED_COLOR=166
RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=161
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="r "}
CWD_THEME_PROMPT_COLOR=240
LAST_STATUS_THEME_PROMPT_COLOR=52
IN_VIM_PROMPT_COLOR=35
IN_VIM_PROMPT_TEXT="vim"
CLOCK_THEME_PROMPT_COLOR=240
BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"}
BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160
function set_rgb_color {
if [[ "${1}" != "-" ]]; then
fg="38;5;${1}"
fi
if [[ "${2}" != "-" ]]; then
bg="48;5;${2}"
[[ -n "${fg}" ]] && bg=";${bg}"
fi
echo -e "\[\033[${fg}${bg}m\]"
}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
function powerline_shell_prompt {
SHELL_PROMPT_COLOR=${SHELL_THEME_PROMPT_COLOR}
if sudo -n uptime 2>&1 | grep -q "load"; then
SHELL_PROMPT_COLOR=${SHELL_THEME_PROMPT_COLOR_SUDO}
fi
if [[ -n "${SSH_CLIENT}" ]]; then
SHELL_PROMPT="${SHELL_SSH_CHAR}\u@\h"
else
SHELL_PROMPT="\u"
fi
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_PROMPT_COLOR}) ${SHELL_PROMPT} ${normal}"
LAST_THEME_COLOR=${SHELL_PROMPT_COLOR}
}
IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim"
function powerline_virtualenv_prompt {
local environ=""
if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
environ="conda: $CONDA_DEFAULT_ENV"
elif [[ -n "$VIRTUAL_ENV" ]]; then
environ=$(basename "$VIRTUAL_ENV")
fi
if [[ -n "$environ" ]]; then
VIRTUALENV_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$environ ${normal}"
LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR}
else
VIRTUALENV_PROMPT=""
fi
}
function powerline_scm_prompt {
scm_prompt_vars
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
if [[ "${SCM_DIRTY}" -eq 3 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_STAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
elif [[ "${SCM_DIRTY}" -eq 2 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_UNSTAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
elif [[ "${SCM_DIRTY}" -eq 1 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})"
else
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})"
fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi
SCM_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${SCM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${SCM_PROMPT} ${normal}"
LAST_THEME_COLOR=${SCM_THEME_PROMPT_COLOR}
else
SCM_PROMPT=""
fi
}
function powerline_cwd_prompt {
CWD_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${CWD_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}"
LAST_THEME_COLOR=${CWD_THEME_PROMPT_COLOR}
}
function powerline_last_status_prompt {
if [[ "$1" -eq 0 ]]; then
LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
else
LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${LAST_STATUS_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${LAST_STATUS_THEME_PROMPT_COLOR}) ${LAST_STATUS} ${normal}$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
fi
}
function powerline_in_vim_prompt {
if [ -z "$VIMRUNTIME" ]; then
IN_VIM_PROMPT=""
else
IN_VIM_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${IN_VIM_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${IN_VIM_PROMPT_COLOR}) ${IN_VIM_PROMPT_TEXT} ${normal}$(set_rgb_color ${IN_VIM_PROMPT_COLOR} -)${normal}"
LAST_THEME_COLOR=${IN_VIM_PROMPT_COLOR}
fi
}
function powerline_prompt_command() {
local LAST_STATUS="$?"
powerline_shell_prompt
powerline_in_vim_prompt
powerline_virtualenv_prompt
powerline_scm_prompt
powerline_cwd_prompt
powerline_last_status_prompt LAST_STATUS
PS1="${SHELL_PROMPT}${IN_VIM_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} "
}
safe_append_prompt_command powerline_prompt_command
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
safe_append_prompt_command __powerline_prompt_command