diff options
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 94 |
1 files changed, 57 insertions, 37 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 97e99f43..07c504fe 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' @@ -569,7 +570,7 @@ prompt_context() { typeset -AH context_states context_states=( "ROOT" "yellow" - "DEFAULT" "011" + "DEFAULT" "yellow" ) local content="" @@ -612,7 +613,7 @@ prompt_user() { "STATE" "DEFAULT" "CONTENT" "$(whoami)" "BACKGROUND_COLOR" "${DEFAULT_COLOR}" - "FOREGROUND_COLOR" "011" + "FOREGROUND_COLOR" "yellow" "VISUAL_IDENTIFIER" "USER_ICON" ) fi @@ -639,7 +640,7 @@ prompt_host() { "STATE" "LOCAL" "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" "BACKGROUND_COLOR" "${DEFAULT_COLOR}" - "FOREGROUND_COLOR" "011" + "FOREGROUND_COLOR" "yellow" "VISUAL_IDENTIFIER" "HOST_ICON" ) fi @@ -686,7 +687,7 @@ prompt_command_execution_time() { fi if (( _P9K_COMMAND_DURATION >= POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD )); then - "$1_prompt_segment" "$0" "$2" "red" "226" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' + "$1_prompt_segment" "$0" "$2" "red" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' fi } @@ -704,10 +705,10 @@ prompt_dir() { case "$POWERLEVEL9K_SHORTEN_STRATEGY" in truncate_middle) - current_path=$(pwd | sed -e "s,^$HOME,~," | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1$POWERLEVEL9K_SHORTEN_DELIMITER\2\//g") + current_path=$(echo "$current_path" | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1$POWERLEVEL9K_SHORTEN_DELIMITER\2\//g") ;; truncate_from_right) - current_path=$(truncatePathFromRight "$(pwd | sed -e "s,^$HOME,~,")" ) + current_path=$(truncatePathFromRight "$current_path" ) ;; truncate_with_package_name) local name repo_path package_path current_dir zero @@ -757,8 +758,12 @@ prompt_dir() { # Instead of printing out the full path, print out the name of the package # from the package.json and append the current subdirectory current_path="`echo $packageName | tr -d '"'`$subdirectory_path" + if [[ "${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" ]]; then + # add space before the packageName to allow for removing the "first" character, without messing up the package name. + current_path=" ${current_path}" + fi else - current_path=$(truncatePathFromRight "$(pwd | sed -e "s,^$HOME,~,")" ) + current_path=$(truncatePathFromRight "$current_path" ) fi ;; truncate_with_folder_marker) @@ -861,13 +866,13 @@ prompt_go_version() { go_path=$(go env GOPATH 2>/dev/null) if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" ]]; then - "$1_prompt_segment" "$0" "$2" "green" "255" "$go_version" "GO_ICON" + "$1_prompt_segment" "$0" "$2" "green" "grey93" "$go_version" "GO_ICON" fi } # Command number (in local history) prompt_history() { - "$1_prompt_segment" "$0" "$2" "244" "$DEFAULT_COLOR" '%h' + "$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" '%h' } # Detection for virtualization (systemd based systems only) @@ -1029,7 +1034,7 @@ prompt_nodeenv() { # print a little OS icon prompt_os_icon() { - "$1_prompt_segment" "$0" "$2" "black" "255" "$OS_ICON" + "$1_prompt_segment" "$0" "$2" "black" "white" "$OS_ICON" } # print PHP version number @@ -1038,7 +1043,7 @@ prompt_php_version() { php_version=$(php -v 2>&1 | grep -oe "^PHP\s*[0-9.]*") if [[ -n "$php_version" ]]; then - "$1_prompt_segment" "$0" "$2" "013" "255" "$php_version" + "$1_prompt_segment" "$0" "$2" "fuchsia" "grey93" "$php_version" fi } @@ -1066,17 +1071,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 } @@ -1104,7 +1109,7 @@ prompt_rust_version() { rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') if [[ -n "$rust_version" ]]; then - "$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' + "$1_prompt_segment" "$0" "$2" "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' fi } # RSpec test ratio @@ -1123,7 +1128,7 @@ prompt_rvm() { local version_and_gemset=${rvm_env_string/ruby-} if [[ -n "$version_and_gemset" ]]; then - "$1_prompt_segment" "$0" "$2" "240" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' + "$1_prompt_segment" "$0" "$2" "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' fi } @@ -1153,7 +1158,7 @@ exit_code_or_status() { else local sig=$(( ec - 128 )) local idx=$(( sig + 1 )) - echo "${signals[$idx]}(-${sig})" + echo "SIG${signals[$idx]}(${sig})" fi } @@ -1179,7 +1184,7 @@ prompt_status() { if (( ec_sum > 0 )); then if [[ "$POWERLEVEL9K_STATUS_CROSS" == false && "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then - "$1_prompt_segment" "$0_ERROR" "$2" "red" "226" "$ec_text" 'CARRIAGE_RETURN_ICON' + "$1_prompt_segment" "$0_ERROR" "$2" "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' else "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' fi @@ -1228,7 +1233,7 @@ prompt_symfony2_version() { if [[ -f app/bootstrap.php.cache ]]; then local symfony2_version symfony2_version=$(grep " VERSION " app/bootstrap.php.cache | sed -e 's/[^.0-9]*//g') - "$1_prompt_segment" "$0" "$2" "240" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' + "$1_prompt_segment" "$0" "$2" "grey35" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' fi } @@ -1262,7 +1267,7 @@ prompt_todo() { if $(hash todo.sh 2>&-); then count=$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }') if [[ "$count" = <-> ]]; then - "$1_prompt_segment" "$0" "$2" "244" "$DEFAULT_COLOR" "$count" 'TODO_ICON' + "$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" "$count" 'TODO_ICON' fi fi } @@ -1401,38 +1406,53 @@ prompt_swift_version() { # dir_writable: Display information about the user's permission to write in the current directory prompt_dir_writable() { if [[ ! -w "$PWD" ]]; then - "$1_prompt_segment" "$0_FORBIDDEN" "$2" "red" "226" "" 'LOCK_ICON' + "$1_prompt_segment" "$0_FORBIDDEN" "$2" "red" "yellow1" "" 'LOCK_ICON' 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) - - if [[ -z "$k8s_namespace" ]]; then - k8s_namespace="default" + 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 [[ "$k8s_context" == "k8s_namespace" ]]; then + if [[ "$cur_ctx" == "cur_namespace" ]]; then # No reason to print out the same identificator twice - k8s_final_text="$k8s_context" + k8s_final_text="$cur_ctx" else - k8s_final_text="$k8s_context/$k8s_namespace" + k8s_final_text="$cur_ctx/$cur_namespace" fi - - + "$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 |