Merge branch 'master' of https://github.com/bash-it/bash-it into ira/autosave-history-plml
* 'master' of https://github.com/bash-it/bash-it: (114 commits) ci: Bump go to 1.17 from 1.14 skip go tests when go is not available plugins: Add ble.sh plugin clean up pyenv plugin Lint: prepare `lib/utilities` for `shellcheck` (#1933) plugin/base: improvements (#1930) plugins/percol: `bind` completion/git: `shfmt` && `shellcheck` completion/git: expand search range plugin/percol: `shellcheck` & `shfmt` plugins/percol: use `_command_exists` completion/pip: simplify code flow plugin/less-pretty-cat: remove `|| cat` completion/wpscan: simplify code flow (whitespace) plugins/less-pretty-cat: simplify code flow plugins/less-pretty-cat: use `_command_exists` lib/helpers: cite `_bash-it-find-in-ancestor()` gradle: adopt `_bash_it_find_in_ancestor()` lib/helpers: new function `_bash-it-find-in-ancestor()` completion/laravel: simplify code flow ...
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
||||
|
||||
# Define this here so it can be used by all of the Powerline themes
|
||||
THEME_CHECK_SUDO=${THEME_CHECK_SUDO:=true}
|
||||
|
||||
@@ -85,6 +88,16 @@ function __powerline_k8s_context_prompt() {
|
||||
[[ -n "${kubernetes_context}" ]] && echo "${KUBERNETES_CONTEXT_THEME_CHAR}${kubernetes_context}|${KUBERNETES_CONTEXT_THEME_PROMPT_COLOR}"
|
||||
}
|
||||
|
||||
function __powerline_k8s_namespace_prompt() {
|
||||
local kubernetes_namespace=""
|
||||
|
||||
if _command_exists kubectl; then
|
||||
kubernetes_namespace="$(k8s_namespace_prompt)"
|
||||
fi
|
||||
|
||||
[[ -n "${kubernetes_namespace}" ]] && echo "${KUBERNETES_NAMESPACE_THEME_CHAR}${kubernetes_namespace}|${KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR}"
|
||||
}
|
||||
|
||||
function __powerline_python_venv_prompt() {
|
||||
set +u
|
||||
local python_venv=""
|
||||
@@ -129,7 +142,7 @@ function __powerline_scm_prompt() {
|
||||
}
|
||||
|
||||
function __powerline_cwd_prompt() {
|
||||
local cwd=$(pwd | sed "s|^${HOME}|~|")
|
||||
local cwd="${PWD/$HOME/\~}"
|
||||
|
||||
echo "${cwd}|${CWD_THEME_PROMPT_COLOR}"
|
||||
}
|
||||
@@ -147,10 +160,10 @@ function __powerline_clock_prompt() {
|
||||
}
|
||||
|
||||
function __powerline_battery_prompt() {
|
||||
local color=""
|
||||
local battery_status="$(battery_percentage 2> /dev/null)"
|
||||
local color="" battery_status
|
||||
battery_status="$(battery_percentage 2> /dev/null)"
|
||||
|
||||
if [[ -z "${battery_status}" ]] || [[ "${battery_status}" = "-1" ]] || [[ "${battery_status}" = "no" ]]; then
|
||||
if [[ -z "${battery_status}" || "${battery_status}" == "-1" || "${battery_status}" == "no" ]]; then
|
||||
true
|
||||
else
|
||||
if [[ "$((10#${battery_status}))" -le 5 ]]; then
|
||||
@@ -166,7 +179,7 @@ function __powerline_battery_prompt() {
|
||||
}
|
||||
|
||||
function __powerline_in_vim_prompt() {
|
||||
if [ -n "$VIMRUNTIME" ]; then
|
||||
if [[ -n "$VIMRUNTIME" ]]; then
|
||||
echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}"
|
||||
fi
|
||||
}
|
||||
@@ -210,6 +223,12 @@ function __powerline_command_number_prompt() {
|
||||
echo "${COMMAND_NUMBER_THEME_PROMPT_CHAR}\#|${COMMAND_NUMBER_THEME_PROMPT_COLOR}"
|
||||
}
|
||||
|
||||
function __powerline_duration_prompt() {
|
||||
local duration
|
||||
duration=$(_command_duration)
|
||||
[[ -n "$duration" ]] && echo "${duration}|${COMMAND_DURATION_PROMPT_COLOR}"
|
||||
}
|
||||
|
||||
function __powerline_left_segment() {
|
||||
local params
|
||||
IFS="|" read -ra params <<< "${1}"
|
||||
@@ -250,7 +269,7 @@ function __powerline_last_status_prompt() {
|
||||
|
||||
function __powerline_prompt_command() {
|
||||
local last_status="$?" ## always the first
|
||||
local separator_char="${POWERLINE_PROMPT_CHAR}"
|
||||
local separator_char="${POWERLINE_PROMPT_CHAR}" info prompt_color
|
||||
|
||||
LEFT_PROMPT=""
|
||||
SEGMENTS_AT_LEFT=0
|
||||
@@ -264,7 +283,7 @@ function __powerline_prompt_command() {
|
||||
|
||||
## left prompt ##
|
||||
for segment in $POWERLINE_PROMPT; do
|
||||
local info="$(__powerline_"${segment}"_prompt)"
|
||||
info="$(__powerline_"${segment}"_prompt)"
|
||||
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
|
||||
done
|
||||
|
||||
@@ -276,7 +295,7 @@ function __powerline_prompt_command() {
|
||||
|
||||
# By default we try to match the prompt to the adjacent segment's background color,
|
||||
# but when part of the prompt exists within that segment, we instead match the foreground color.
|
||||
local prompt_color="$(set_color "${LAST_SEGMENT_COLOR}" -)"
|
||||
prompt_color="$(set_color "${LAST_SEGMENT_COLOR}" -)"
|
||||
if [[ -n "${LEFT_PROMPT}" ]] && [[ -n "${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}" ]]; then
|
||||
LEFT_PROMPT+="$(set_color - "${LAST_SEGMENT_COLOR}")${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}"
|
||||
prompt_color="${normal}"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
|
||||
# shellcheck source=../../themes/powerline/powerline.base.bash
|
||||
. "$BASH_IT/themes/powerline/powerline.base.bash"
|
||||
@@ -52,6 +53,9 @@ TERRAFORM_CHAR=${POWERLINE_TERRAFORM_CHAR:="❲t❳ "}
|
||||
KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "}
|
||||
KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_CONTEXT_COLOR:=26}
|
||||
|
||||
KUBERNETES_NAMESPACE_THEME_CHAR=${POWERLINE_KUBERNETES_NAMESPACE_CHAR:="⎈ "}
|
||||
KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_NAMESPACE_COLOR:=64}
|
||||
|
||||
AWS_PROFILE_CHAR=${POWERLINE_AWS_PROFILE_CHAR:="❲aws❳ "}
|
||||
AWS_PROFILE_PROMPT_COLOR=${POWERLINE_AWS_PROFILE_COLOR:=208}
|
||||
|
||||
@@ -91,6 +95,8 @@ COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"}
|
||||
GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161}
|
||||
GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="❲G❳ "}
|
||||
|
||||
COMMAND_DURATION_PROMPT_COLOR=${POWERLINE_COMMAND_DURATION_COLOR:=129}
|
||||
|
||||
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"}
|
||||
|
||||
safe_append_prompt_command __powerline_prompt_command
|
||||
|
||||
Reference in New Issue
Block a user