Upload files to "powerline"
This commit is contained in:
parent
5b16bc4a8e
commit
94fd54a2be
|
@ -0,0 +1,440 @@
|
|||
|
||||
# shellcheck shell=bash
|
||||
|
||||
_lp_powerline_theme_activate() {
|
||||
# Load default markers if not already defined
|
||||
POWERLINE_HARD_DIVIDER=${POWERLINE_HARD_DIVIDER:-""} # U+E0B0
|
||||
POWERLINE_SOFT_DIVIDER=${POWERLINE_SOFT_DIVIDER:-""} # U+E0B1
|
||||
POWERLINE_VCS_MARKER=${POWERLINE_VCS_MARKER:-""} # U+E0A0
|
||||
POWERLINE_SECURE_MARKER=${POWERLINE_SECURE_MARKER:-""} # U+E0A2
|
||||
POWERLINE_ROOT_MARKER=${POWERLINE_ROOT_MARKER:-"#"}
|
||||
POWERLINE_STASH_MARKER=${POWERLINE_STASH_MARKER:-"ST"}
|
||||
POWERLINE_PYTHON_ENV_MARKER=${POWERLINE_PYTHON_ENV_MARKER:-"(e) "}
|
||||
POWERLINE_SPACER=${POWERLINE_SPACER:-" "} # U+00A0 non-breaking space
|
||||
|
||||
# Load default colors if not already defined
|
||||
POWERLINE_HOST_COLOR=( ${POWERLINE_HOST_COLOR[@]+"${POWERLINE_HOST_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_HOST_COLOR[@]} == 0 ]] && POWERLINE_HOST_COLOR=(220 166 0 0 3 2)
|
||||
|
||||
POWERLINE_USER_COLOR=( ${POWERLINE_USER_COLOR[@]+"${POWERLINE_USER_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_USER_COLOR[@]} == 0 ]] && POWERLINE_USER_COLOR=(231 31 1 0 7 6)
|
||||
|
||||
POWERLINE_PYTHON_ENV_COLOR=( ${POWERLINE_PYTHON_ENV_COLOR[@]+"${POWERLINE_PYTHON_ENV_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_PYTHON_ENV_COLOR[@]} == 0 ]] && POWERLINE_PYTHON_ENV_COLOR=(231 74 0 0 7 4)
|
||||
|
||||
POWERLINE_PATH_COLOR=( ${POWERLINE_PATH_COLOR[@]+"${POWERLINE_PATH_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_PATH_COLOR[@]} == 0 ]] && POWERLINE_PATH_COLOR=(250 240 0 0 7 0)
|
||||
|
||||
POWERLINE_PATH_SEPARATOR_COLOR=( ${POWERLINE_PATH_SEPARATOR_COLOR[@]+"${POWERLINE_PATH_SEPARATOR_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_PATH_SEPARATOR_COLOR[@]} == 0 ]] && POWERLINE_PATH_SEPARATOR_COLOR=(245 240 0 0 7 0)
|
||||
|
||||
POWERLINE_PATH_LAST_COLOR=( ${POWERLINE_PATH_LAST_COLOR[@]+"${POWERLINE_PATH_LAST_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_PATH_LAST_COLOR[@]} == 0 ]] && POWERLINE_PATH_LAST_COLOR=(252 240 1 0 7 0)
|
||||
|
||||
POWERLINE_PATH_VCS_COLOR=( ${POWERLINE_PATH_VCS_COLOR[@]+"${POWERLINE_PATH_VCS_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_PATH_VCS_COLOR[@]} == 0 ]] && POWERLINE_PATH_VCS_COLOR=(147 240 1 0 4 0)
|
||||
|
||||
POWERLINE_PATH_SHORTENED_COLOR=( ${POWERLINE_PATH_SHORTENED_COLOR[@]+"${POWERLINE_PATH_SHORTENED_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_PATH_SHORTENED_COLOR[@]} == 0 ]] && POWERLINE_PATH_SHORTENED_COLOR=(245 240 0 0 7 0)
|
||||
|
||||
POWERLINE_JOBS_COLOR=( ${POWERLINE_JOBS_COLOR[@]+"${POWERLINE_JOBS_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_JOBS_COLOR[@]} == 0 ]] && POWERLINE_JOBS_COLOR=(220 166 0 0 3 2)
|
||||
|
||||
POWERLINE_VCS_CLEAN_COLOR=( ${POWERLINE_VCS_CLEAN_COLOR[@]+"${POWERLINE_VCS_CLEAN_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_VCS_CLEAN_COLOR[@]} == 0 ]] && POWERLINE_VCS_CLEAN_COLOR=(250 236 0 0 7 0)
|
||||
|
||||
POWERLINE_VCS_DIRTY_COLOR=( ${POWERLINE_VCS_DIRTY_COLOR[@]+"${POWERLINE_VCS_DIRTY_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_VCS_DIRTY_COLOR[@]} == 0 ]] && POWERLINE_VCS_DIRTY_COLOR=(220 236 0 0 3 0)
|
||||
|
||||
POWERLINE_VCS_STASH_COLOR=( ${POWERLINE_VCS_STASH_COLOR[@]+"${POWERLINE_VCS_STASH_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_VCS_STASH_COLOR[@]} == 0 ]] && POWERLINE_VCS_STASH_COLOR=(220 236 0 0 3 0)
|
||||
|
||||
POWERLINE_ERROR_COLOR=( ${POWERLINE_ERROR_COLOR[@]+"${POWERLINE_ERROR_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_ERROR_COLOR[@]} == 0 ]] && POWERLINE_ERROR_COLOR=(231 52 0 0 7 1)
|
||||
|
||||
__powerline_hostname_generate
|
||||
__powerline_username_generate
|
||||
}
|
||||
|
||||
__powerline_hostname_generate() {
|
||||
_POWERLINE_HOSTNAME="" _POWERLINE_HOST_ICON=""
|
||||
local lp_hostname lp_connection
|
||||
if _lp_hostname; then
|
||||
_POWERLINE_HOSTNAME=${lp_hostname}
|
||||
|
||||
case "$lp_connection" in
|
||||
ssh) _POWERLINE_HOST_ICON="${POWERLINE_SECURE_MARKER} " ;;
|
||||
su) _POWERLINE_HOST_ICON="${POWERLINE_ROOT_MARKER} " ;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
__powerline_username_generate() {
|
||||
_POWERLINE_USERNAME=
|
||||
local lp_username
|
||||
if _lp_username; then
|
||||
_POWERLINE_USERNAME=${lp_username}
|
||||
fi
|
||||
}
|
||||
|
||||
_lp_powerline_theme_directory() {
|
||||
# Not all terminals support Powerline special characters in the title
|
||||
local title=
|
||||
title+=${lp_username_raw-}
|
||||
title+="${lp_hostname_raw+@}${lp_hostname_raw-}"
|
||||
|
||||
local lp_path
|
||||
__powerline_path_generate
|
||||
|
||||
[[ -n $title ]] && title+=":"
|
||||
title+="${lp_path}"
|
||||
|
||||
# Include a trailing space to pad for the title command.
|
||||
_lp_raw_title "$title "
|
||||
}
|
||||
|
||||
_lp_powerline_theme_prompt() {
|
||||
local powerline_sections first_section sub_section_format _lp_last_af_color _lp_last_ab_color
|
||||
|
||||
__powerline_section "${_POWERLINE_HOST_ICON}${_POWERLINE_HOSTNAME}" "${POWERLINE_HOST_COLOR[@]}"
|
||||
|
||||
__powerline_section "$_POWERLINE_USERNAME" "${POWERLINE_USER_COLOR[@]}"
|
||||
|
||||
local lp_python_env
|
||||
if _lp_python_env; then
|
||||
__powerline_section "${POWERLINE_PYTHON_ENV_MARKER}${lp_python_env}" "${POWERLINE_PYTHON_ENV_COLOR[@]}"
|
||||
fi
|
||||
|
||||
__powerline_section "$_lp_powerline_path" "${POWERLINE_PATH_COLOR[@]}"
|
||||
|
||||
local lp_running_jobs lp_stopped_jobs
|
||||
if _lp_jobcount; then
|
||||
__powerline_section "$(( lp_running_jobs + lp_stopped_jobs ))" "${POWERLINE_JOBS_COLOR[@]}"
|
||||
fi
|
||||
|
||||
# TODO render on left side
|
||||
local lp_vcs_type lp_vcs_root
|
||||
if _lp_find_vcs; then
|
||||
local lp_vcs_branch lp_vcs_uncommitted_files lp_vcs_untracked_files
|
||||
_lp_vcs_branch
|
||||
|
||||
if _lp_vcs_uncommitted_files || _lp_vcs_untracked_files; then
|
||||
__powerline_section "${POWERLINE_VCS_MARKER} ${lp_vcs_branch}" "${POWERLINE_VCS_DIRTY_COLOR[@]}"
|
||||
else
|
||||
__powerline_section "${POWERLINE_VCS_MARKER} ${lp_vcs_branch}" "${POWERLINE_VCS_CLEAN_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_vcs_stash_count
|
||||
if _lp_vcs_stash_count; then
|
||||
__powerline_sub_section_format -2
|
||||
powerline_sections+="${sub_section_format}${POWERLINE_SOFT_DIVIDER}"
|
||||
|
||||
__powerline_section "${POWERLINE_STASH_MARKER} ${lp_vcs_stash_count}" "${POWERLINE_VCS_STASH_COLOR[@]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if _lp_error; then
|
||||
__powerline_section "${lp_error}" "${POWERLINE_ERROR_COLOR[@]}"
|
||||
fi
|
||||
|
||||
__powerline_end_terminator
|
||||
|
||||
PS1=${powerline_sections}
|
||||
}
|
||||
|
||||
_lp_powerline_full_theme_activate() {
|
||||
_lp_powerline_theme_activate
|
||||
|
||||
# Load default markers if not already defined
|
||||
POWERLINE_AWS_PROFILE_MARKER=${POWERLINE_AWS_PROFILE_MARKER:-"AWS: "}
|
||||
POWERLINE_CHROOT_MARKER=${POWERLINE_CHROOT_MARKER:-"chroot: "}
|
||||
POWERLINE_KUBECONTEXT_MARKER=${POWERLINE_KUBECONTEXT_MARKER:-$LP_MARK_KUBECONTEXT}
|
||||
POWERLINE_NODE_ENV_MARKER=${POWERLINE_NODE_ENV_MARKER:-"node: "}
|
||||
POWERLINE_PROXY_MARKER=${POWERLINE_PROXY_MARKER:-"proxy: "}
|
||||
POWERLINE_RUBY_ENV_MARKER=${POWERLINE_RUBY_ENV_MARKER:-"ruby: "}
|
||||
POWERLINE_SOFTWARE_COLLECTION_MARKER=${POWERLINE_SOFTWARE_COLLECTION_MARKER:-"(sc) "}
|
||||
POWERLINE_TERRAFORM_ENV_MARKER=${POWERLINE_TERRAFORM_ENV_MARKER:-"(tf) "}
|
||||
|
||||
# Load default colors if not already defined
|
||||
POWERLINE_NEUTRAL_COLOR=( ${POWERLINE_NEUTRAL_COLOR[@]+"${POWERLINE_NEUTRAL_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_NEUTRAL_COLOR[@]} == 0 ]] && POWERLINE_NEUTRAL_COLOR=(252 234 0 0 7 0)
|
||||
|
||||
POWERLINE_AWS_PROFILE_COLOR=( ${POWERLINE_AWS_PROFILE_COLOR[@]+"${POWERLINE_AWS_PROFILE_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_AWS_PROFILE_COLOR[@]} == 0 ]] && POWERLINE_AWS_PROFILE_COLOR=(190 236 0 0 3 0)
|
||||
|
||||
POWERLINE_BATTERY_COLOR=( ${POWERLINE_BATTERY_COLOR[@]+"${POWERLINE_BATTERY_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_BATTERY_COLOR[@]} == 0 ]] && POWERLINE_BATTERY_COLOR=(-1 238 0 0 -1 0)
|
||||
|
||||
POWERLINE_CHROOT_COLOR=( ${POWERLINE_CHROOT_COLOR[@]+"${POWERLINE_CHROOT_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_CHROOT_COLOR[@]} == 0 ]] && POWERLINE_CHROOT_COLOR=(219 30 0 0 7 4)
|
||||
|
||||
POWERLINE_CONTAINER_COLOR=( ${POWERLINE_CONTAINER_COLOR[@]+"${POWERLINE_CONTAINER_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_CONTAINER_COLOR[@]} == 0 ]] && POWERLINE_CONTAINER_COLOR=("${POWERLINE_NEUTRAL_COLOR[@]}")
|
||||
|
||||
POWERLINE_DIRSTACK_COLOR=( ${POWERLINE_DIRSTACK_COLOR[@]+"${POWERLINE_DIRSTACK_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_DIRSTACK_COLOR[@]} == 0 ]] && POWERLINE_DIRSTACK_COLOR=("${POWERLINE_NEUTRAL_COLOR[@]}")
|
||||
|
||||
POWERLINE_KUBECONTEXT_COLOR=( ${POWERLINE_KUBECONTEXT_COLOR[@]+"${POWERLINE_KUBECONTEXT_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_KUBECONTEXT_COLOR[@]} == 0 ]] && POWERLINE_KUBECONTEXT_COLOR=(231 74 0 0 7 4)
|
||||
|
||||
POWERLINE_LOAD_COLOR=( ${POWERLINE_LOAD_COLOR[@]+"${POWERLINE_LOAD_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_LOAD_COLOR[@]} == 0 ]] && POWERLINE_LOAD_COLOR=(-1 148 0 0 -1 3)
|
||||
|
||||
POWERLINE_NODE_ENV_COLOR=( ${POWERLINE_NODE_ENV_COLOR[@]+"${POWERLINE_NODE_ENV_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_NODE_ENV_COLOR[@]} == 0 ]] && POWERLINE_NODE_ENV_COLOR=("${POWERLINE_PYTHON_ENV_COLOR[@]}")
|
||||
|
||||
POWERLINE_PROXY_COLOR=( ${POWERLINE_PROXY_COLOR[@]+"${POWERLINE_PROXY_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_PROXY_COLOR[@]} == 0 ]] && POWERLINE_PROXY_COLOR=(21 219 1 0 4 7)
|
||||
|
||||
POWERLINE_RUBY_ENV_COLOR=( ${POWERLINE_RUBY_ENV_COLOR[@]+"${POWERLINE_RUBY_ENV_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_RUBY_ENV_COLOR[@]} == 0 ]] && POWERLINE_RUBY_ENV_COLOR=("${POWERLINE_PYTHON_ENV_COLOR[@]}")
|
||||
|
||||
POWERLINE_RUNTIME_COLOR=( ${POWERLINE_RUNTIME_COLOR[@]+"${POWERLINE_RUNTIME_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_RUNTIME_COLOR[@]} == 0 ]] && POWERLINE_RUNTIME_COLOR=(226 17 0 0 3 4)
|
||||
|
||||
POWERLINE_SHLVL_COLOR=( ${POWERLINE_SHLVL_COLOR[@]+"${POWERLINE_SHLVL_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_SHLVL_COLOR[@]} == 0 ]] && POWERLINE_SHLVL_COLOR=(231 58 0 0 7 2)
|
||||
|
||||
POWERLINE_SOFTWARE_COLLECTIONS_COLOR=( ${POWERLINE_SOFTWARE_COLLECTIONS_COLOR[@]+"${POWERLINE_SOFTWARE_COLLECTIONS_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_SOFTWARE_COLLECTIONS_COLOR[@]} == 0 ]] && POWERLINE_SOFTWARE_COLLECTIONS_COLOR=(231 62 0 0 7 5)
|
||||
|
||||
POWERLINE_TEMPERATURE_COLOR=( ${POWERLINE_TEMPERATURE_COLOR[@]+"${POWERLINE_TEMPERATURE_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_TEMPERATURE_COLOR[@]} == 0 ]] && POWERLINE_TEMPERATURE_COLOR=(-1 240 0 0 -1 0)
|
||||
|
||||
POWERLINE_TERRAFORM_ENV_COLOR=( ${POWERLINE_TERRAFORM_ENV_COLOR[@]+"${POWERLINE_TERRAFORM_ENV_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_TERRAFORM_ENV_COLOR[@]} == 0 ]] && POWERLINE_TERRAFORM_ENV_COLOR=(231 182 0 0 7 4)
|
||||
|
||||
POWERLINE_TIME_COLOR=( ${POWERLINE_TIME_COLOR[@]+"${POWERLINE_TIME_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_TIME_COLOR[@]} == 0 ]] && POWERLINE_TIME_COLOR=(33 17 0 0 5 4)
|
||||
|
||||
POWERLINE_WIFI_STRENGTH_COLOR=( ${POWERLINE_WIFI_STRENGTH_COLOR[@]+"${POWERLINE_WIFI_STRENGTH_COLOR[@]}"} )
|
||||
[[ ${#POWERLINE_WIFI_STRENGTH_COLOR[@]} == 0 ]] && POWERLINE_WIFI_STRENGTH_COLOR=(-1 148 0 0 -1 3)
|
||||
}
|
||||
|
||||
_lp_powerline_full_theme_directory() {
|
||||
_lp_powerline_theme_directory
|
||||
}
|
||||
|
||||
_lp_powerline_full_theme_prompt() {
|
||||
local powerline_sections first_section _lp_last_af_color _lp_last_ab_color
|
||||
|
||||
__powerline_section "$LP_PS1_PREFIX" "${POWERLINE_NEUTRAL_COLOR[@]}"
|
||||
|
||||
local lp_time lp_analog_time
|
||||
if _lp_time; then
|
||||
__powerline_section "$lp_time" "${POWERLINE_TIME_COLOR[@]}"
|
||||
elif _lp_analog_time; then
|
||||
__powerline_section "$lp_analog_time" "${POWERLINE_TIME_COLOR[@]}"
|
||||
fi
|
||||
|
||||
__powerline_battery_section
|
||||
|
||||
local lp_load_color
|
||||
if _lp_load_color; then
|
||||
__powerline_formatted_section "$lp_load_color" "${POWERLINE_LOAD_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_temperature_color
|
||||
if _lp_temperature_color; then
|
||||
__powerline_formatted_section "$lp_temperature_color" "${POWERLINE_TEMPERATURE_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_wifi_signal_strength_color
|
||||
if _lp_wifi_signal_strength_color; then
|
||||
__powerline_formatted_section "$lp_wifi_signal_strength_color" "${POWERLINE_WIFI_STRENGTH_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_detached_sessions lp_running_jobs lp_stopped_jobs jobs_string=
|
||||
if _lp_detached_sessions; then
|
||||
jobs_string="${lp_detached_sessions}d"
|
||||
fi
|
||||
if _lp_jobcount; then
|
||||
if (( lp_running_jobs > 0 )); then
|
||||
[[ -n $jobs_string ]] && jobs_string+='/'
|
||||
jobs_string+="${lp_running_jobs}&"
|
||||
fi
|
||||
if (( lp_stopped_jobs > 0 )); then
|
||||
[[ -n $jobs_string ]] && jobs_string+='/'
|
||||
jobs_string+="${lp_stopped_jobs}z"
|
||||
fi
|
||||
fi
|
||||
__powerline_section "$jobs_string" "${POWERLINE_JOBS_COLOR[@]}"
|
||||
|
||||
__powerline_section "$_POWERLINE_USERNAME" "${POWERLINE_USER_COLOR[@]}"
|
||||
|
||||
__powerline_section "${_POWERLINE_HOST_ICON}${_POWERLINE_HOSTNAME}" "${POWERLINE_HOST_COLOR[@]}"
|
||||
|
||||
__powerline_section "$_lp_powerline_path" "${POWERLINE_PATH_COLOR[@]}"
|
||||
|
||||
if _lp_dirstack; then
|
||||
__powerline_section "${LP_MARK_DIRSTACK}${lp_dirstack}" "${POWERLINE_DIRSTACK_COLOR[@]}"
|
||||
fi
|
||||
|
||||
if _lp_shell_level; then
|
||||
__powerline_section "${LP_MARK_SHLVL}${lp_shell_level}" "${POWERLINE_SHLVL_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_chroot
|
||||
if _lp_chroot; then
|
||||
__powerline_section "${POWERLINE_CHROOT_MARKER}${lp_chroot}" "${POWERLINE_CHROOT_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_software_collections
|
||||
if _lp_software_collections; then
|
||||
__powerline_section "${POWERLINE_SOFTWARE_COLLECTION_MARKER}${lp_software_collections}" "${POWERLINE_SOFTWARE_COLLECTIONS_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_aws_profile
|
||||
if _lp_aws_profile; then
|
||||
__powerline_section "${POWERLINE_AWS_PROFILE_MARKER}${lp_aws_profile}" "${POWERLINE_AWS_PROFILE_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_python_env
|
||||
if _lp_python_env; then
|
||||
__powerline_section "${POWERLINE_PYTHON_ENV_MARKER}${lp_python_env}" "${POWERLINE_PYTHON_ENV_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_node_env
|
||||
if _lp_node_env; then
|
||||
__powerline_section "${POWERLINE_NODE_ENV_MARKER}${lp_node_env}" "${POWERLINE_NODE_ENV_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_ruby_env
|
||||
if _lp_ruby_env; then
|
||||
__powerline_section "${POWERLINE_RUBY_ENV_MARKER}${lp_ruby_env}" "${POWERLINE_RUBY_ENV_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_kubernetes_context
|
||||
if _lp_kubernetes_context; then
|
||||
__powerline_section "${POWERLINE_KUBECONTEXT_MARKER}${lp_kubernetes_context}" "${POWERLINE_KUBECONTEXT_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_terraform_env
|
||||
if _lp_terraform_env; then
|
||||
__powerline_section "${POWERLINE_TERRAFORM_ENV_MARKER}${lp_terraform_env}" "${POWERLINE_TERRAFORM_ENV_COLOR[@]}"
|
||||
fi
|
||||
|
||||
local lp_http_proxy
|
||||
if _lp_http_proxy; then
|
||||
__powerline_section "${POWERLINE_PROXY_MARKER}${lp_http_proxy}" "${POWERLINE_PROXY_COLOR[@]}"
|
||||
fi
|
||||
|
||||
__powerline_vcs_section
|
||||
|
||||
if _lp_runtime_format; then
|
||||
__powerline_section "${lp_runtime_format}" "${POWERLINE_RUNTIME_COLOR[@]}"
|
||||
fi
|
||||
|
||||
if _lp_error; then
|
||||
__powerline_section "${lp_error}" "${POWERLINE_ERROR_COLOR[@]}"
|
||||
fi
|
||||
|
||||
__powerline_section "$LP_PS1_POSTFIX" "${POWERLINE_NEUTRAL_COLOR[@]}"
|
||||
|
||||
__powerline_end_terminator
|
||||
|
||||
PS1=$powerline_sections
|
||||
}
|
||||
|
||||
__powerline_section() { # string, (color array)
|
||||
local section_arrow lp_terminal_format string="${1-}"
|
||||
shift
|
||||
|
||||
[[ -z $string ]] && return 1
|
||||
|
||||
__powerline_section_arrow "$@"
|
||||
lp_terminal_format "$@"
|
||||
|
||||
powerline_sections+="${section_arrow}${lp_terminal_format}${POWERLINE_SPACER}${string}${POWERLINE_SPACER}"
|
||||
}
|
||||
|
||||
# Same as __powerline_section(), but it resets formatting after the input string
|
||||
__powerline_formatted_section() {
|
||||
local section_arrow lp_terminal_format string="${1-}"
|
||||
shift
|
||||
|
||||
[[ -z $string ]] && return 1
|
||||
|
||||
__powerline_section_arrow "$@"
|
||||
lp_terminal_format "$@"
|
||||
|
||||
powerline_sections+="${section_arrow}${lp_terminal_format}${POWERLINE_SPACER}${string}${lp_terminal_format}${POWERLINE_SPACER}"
|
||||
}
|
||||
|
||||
# Reset background for end of prompt
|
||||
__powerline_end_terminator() {
|
||||
# Always add a end terminator, even if nothing is before it
|
||||
local first_section="true"
|
||||
__powerline_section_arrow -1
|
||||
lp_terminal_format -1
|
||||
powerline_sections+="${section_arrow}${lp_terminal_format}${POWERLINE_SPACER}"
|
||||
}
|
||||
|
||||
__powerline_section_arrow() { # _, background_color, _, _, _, fallback_background_color
|
||||
if [[ -n ${first_section-} ]]; then
|
||||
local lp_terminal_format
|
||||
lp_terminal_format -3 "${2-}" 0 0 -1 "${6-}"
|
||||
section_arrow="${lp_terminal_format}${POWERLINE_HARD_DIVIDER}"
|
||||
else
|
||||
first_section="true"
|
||||
section_arrow=
|
||||
fi
|
||||
}
|
||||
|
||||
__powerline_sub_section_format() { # foreground_color, _, _, _, fallback_foreground_color
|
||||
local lp_terminal_format
|
||||
lp_terminal_format "${1-}" -2 0 0 "${5-}"
|
||||
sub_section_format="${lp_terminal_format}"
|
||||
}
|
||||
|
||||
# We don't want to generate the path every prompt, so create the full formatted
|
||||
# path once for each dir.
|
||||
__powerline_path_generate() {
|
||||
local lp_terminal_format sub_section_format _lp_last_af_color _lp_last_ab_color
|
||||
|
||||
lp_terminal_format "${POWERLINE_PATH_COLOR[@]}"
|
||||
local path_format="$lp_terminal_format"
|
||||
|
||||
__powerline_sub_section_format "${POWERLINE_PATH_SEPARATOR_COLOR[@]}"
|
||||
local separator_format="$sub_section_format"
|
||||
|
||||
lp_terminal_format "${POWERLINE_PATH_SHORTENED_COLOR[@]}"
|
||||
local shortened_format="$lp_terminal_format"
|
||||
|
||||
lp_terminal_format "${POWERLINE_PATH_VCS_COLOR[@]}"
|
||||
local vcs_format="$lp_terminal_format"
|
||||
|
||||
lp_terminal_format "${POWERLINE_PATH_LAST_COLOR[@]}"
|
||||
local last_dir_format="$lp_terminal_format"
|
||||
|
||||
local lp_path_format
|
||||
_lp_path_format "$path_format" "$last_dir_format" "$vcs_format" "$shortened_format" \
|
||||
"${POWERLINE_SPACER}${POWERLINE_SOFT_DIVIDER}${POWERLINE_SPACER}" "$separator_format"
|
||||
|
||||
_lp_powerline_path=${lp_path_format}
|
||||
}
|
||||
|
||||
# Is this a dirty hack? Yes. Am I proud of it? Also yes.
|
||||
__powerline_battery_section() {
|
||||
local lp_battery_color NO_COL=''
|
||||
if _lp_battery_color; then
|
||||
__powerline_formatted_section "$lp_battery_color" "${POWERLINE_BATTERY_COLOR[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
__powerline_vcs_section() {
|
||||
local lp_vcs_type lp_vcs_root
|
||||
if _lp_find_vcs; then
|
||||
local section_arrow lp_terminal_format
|
||||
|
||||
__powerline_section_arrow "${POWERLINE_VCS_CLEAN_COLOR[@]}"
|
||||
lp_terminal_format "${POWERLINE_VCS_CLEAN_COLOR[@]}"
|
||||
|
||||
local lp_vcs_details_color NO_COL="$lp_terminal_format"
|
||||
_lp_vcs_details_color
|
||||
|
||||
powerline_sections+="${section_arrow}${lp_terminal_format}${POWERLINE_SPACER}${lp_vcs_details_color}${POWERLINE_SPACER}"
|
||||
fi
|
||||
}
|
||||
|
||||
# vim: ft=sh et sts=4 sw=4 tw=120
|
Loading…
Reference in New Issue