summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme55
1 files changed, 41 insertions, 14 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index b4ccb389..4e7f4316 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -305,6 +305,7 @@ prompt_aws_eb_env() {
# Segment to indicate background jobs with an icon.
set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE true
+set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS false
prompt_background_jobs() {
local background_jobs_number=${$(jobs -l | wc -l)// /}
local wrong_lines=`jobs -l | awk '/pwd now/{ count++ } END {print count}'`
@@ -313,7 +314,7 @@ prompt_background_jobs() {
fi
if [[ background_jobs_number -gt 0 ]]; then
local background_jobs_number_print=""
- if [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE" == "true" ]] && [[ "$background_jobs_number" -gt 1 ]]; then
+ if [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE" == "true" ]] && ([[ "$background_jobs_number" -gt 1 ]] || [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS" == "true" ]]); then
background_jobs_number_print="$background_jobs_number"
fi
"$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "cyan" "$background_jobs_number_print" 'BACKGROUND_JOBS_ICON'
@@ -1067,17 +1068,17 @@ prompt_ram() {
}
# rbenv information
+set_default POWERLEVEL9K_RBENV_ALWAYS false
prompt_rbenv() {
if which rbenv 2>/dev/null >&2; then
local rbenv_version_name="$(rbenv version-name)"
local rbenv_global="$(rbenv global)"
- # Don't show anything if the current Ruby is the same as the global Ruby.
- if [[ $rbenv_version_name == $rbenv_global ]]; then
- return
+ # Don't show anything if the current Ruby is the same as the global Ruby
+ # unless `POWERLEVEL9K_RBENV_ALWAYS` is set.
+ if [[ $POWERLEVEL9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then
+ "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON'
fi
-
- "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON'
fi
}
@@ -1154,7 +1155,7 @@ exit_code_or_status() {
else
local sig=$(( ec - 128 ))
local idx=$(( sig + 1 ))
- echo "${signals[$idx]}(-${sig})"
+ echo "SIG${signals[$idx]}(${sig})"
fi
}
@@ -1414,23 +1415,49 @@ prompt_dir_writable() {
fi
}
-# Kubernetes Current Context
+# Kubernetes Current Context/Namespace
prompt_kubecontext() {
local kubectl_version="$(kubectl version --client 2>/dev/null)"
if [[ -n "$kubectl_version" ]]; then
- # Get the current Kubernetes config context's namespaece
- local k8s_namespace=$(kubectl config get-contexts --no-headers | grep '*' | awk '{print $5}')
# Get the current Kuberenetes context
- local k8s_context=$(kubectl config current-context)
+ local cur_ctx=$(kubectl config view -o=jsonpath='{.current-context}')
+ cur_namespace="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${cur_ctx}\")].context.namespace}")"
+ # If the namespace comes back empty set it default.
+ if [[ -z "${cur_namespace}" ]]; then
+ cur_namespace="default"
+ fi
+
+ local k8s_final_text=""
- if [[ -z "$k8s_namespace" ]]; then
- k8s_namespace="default"
+ if [[ "$k8s_context" == "k8s_namespace" ]]; then
+ # No reason to print out the same identificator twice
+ k8s_final_text="$k8s_context"
+ else
+ k8s_final_text="$k8s_context/$k8s_namespace"
fi
- "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_context/$k8s_namespace" "KUBERNETES_ICON"
+
+ "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON"
fi
}
+# Dropbox status
+prompt_dropbox() {
+ # The first column is just the directory, so cut it
+ local dropbox_status="$(dropbox-cli filestatus . | cut -d\ -f2-)"
+
+ # Only show if the folder is tracked and dropbox is running
+ if [[ "$dropbox_status" != 'unwatched' && "$dropbox_status" != "isn't running!" ]]; then
+ # If "up to date", only show the icon
+ if [[ "$dropbox_status" =~ 'up to date' ]]; then
+ dropbox_status=""
+ fi
+
+ "$1_prompt_segment" "$0" "$2" "white" "blue" "$dropbox_status" "DROPBOX_ICON"
+ fi
+
+}
+
################################################################
# Prompt processing and drawing