diff options
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 8379f68a..436398c0 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -278,7 +278,7 @@ CURRENT_BG='NONE' prompt_anaconda() { # Depending on the conda version, either might be set. This # variant works even if both are set. - _path=$CONDA_ENV_PATH$CONDA_PREFIX + local _path=$CONDA_ENV_PATH$CONDA_PREFIX if ! [ -z "$_path" ]; then # config - can be overwritten in users' zshrc file. set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "(" @@ -895,7 +895,9 @@ prompt_dir() { fi ;; *) - current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + if [[ $current_path != "~" ]]; then + current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + fi ;; esac fi @@ -921,7 +923,7 @@ prompt_dir() { fi # declare variables used for bold and state colors - local bld dir_state_foreground dir_state_user_foreground + local bld_on bld_off dir_state_foreground dir_state_user_foreground # test if user wants the last directory printed in bold if [[ "${(L)POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD}" == "true" ]]; then bld_on="%B" @@ -1229,18 +1231,19 @@ prompt_ram() { "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' } -################################################################ -# Segment to display rbenv information -set_default POWERLEVEL9K_RBENV_ALWAYS false + +set_default POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW false +# rbenv information prompt_rbenv() { - if which rbenv 2>/dev/null >&2; then + if command 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 - # 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' + # unless `POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW` is set. + if [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then + return fi fi } @@ -1337,8 +1340,13 @@ prompt_status() { local ec if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then - ec_text=$(exit_code_or_status "${RETVALS[1]}") - ec_sum=${RETVALS[1]} + if (( $#RETVALS > 1 )); then + ec_text=$(exit_code_or_status "${RETVALS[1]}") + ec_sum=${RETVALS[1]} + else + ec_text=$(exit_code_or_status "${RETVAL}") + ec_sum=${RETVAL} + fi for ec in "${(@)RETVALS[2,-1]}"; do ec_text="${ec_text}|$(exit_code_or_status "$ec")" @@ -1685,6 +1693,7 @@ build_left_prompt() { # Right prompt build_right_prompt() { local index=1 + local element for element in "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]}"; do # Remove joined information in direct calls element=${element%_joined} @@ -1707,6 +1716,7 @@ powerlevel9k_preexec() { set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false powerlevel9k_prepare_prompts() { + local RETVAL RPROMPT_PREFIX RPROMPT_SUFFIX RETVAL=$? RETVALS=( "$pipestatus[@]" ) @@ -1741,7 +1751,7 @@ $(print_icon 'MULTILINE_LAST_PROMPT_PREFIX')' RPROMPT='$RPROMPT_PREFIX%f%b%k$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX' fi -NEWLINE=' +local NEWLINE=' ' if [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]]; then |