diff options
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 49e066a5..f55f4811 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -409,7 +409,7 @@ prompt_battery() { local time_remaining=$(acpi | awk '{ print $5 }') if [[ $time_remaining =~ rate ]]; then local tstring="..." - elif [[ $time_remaining =~ "[:digit:]+" ]]; then + elif [[ $time_remaining =~ "[[:digit:]]+" ]]; then local tstring=${(f)$(date -u -d "$(echo $time_remaining)" +%k:%M)} fi fi @@ -456,6 +456,7 @@ prompt_custom() { } # Dir: current working directory +set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" prompt_dir() { local current_path='%~' if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" ]]; then @@ -501,17 +502,25 @@ prompt_dir() { current_path="%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c" ;; esac + fi + if [[ "${POWERLEVEL9K_DIR_PATH_SEPARATOR}" != "/" ]]; then + current_path=$(print -P "${current_path}" | sed "s/\//${POWERLEVEL9K_DIR_PATH_SEPARATOR}/g") fi - local current_icon='' + typeset -AH dir_states + dir_states=( + "DEFAULT" "FOLDER_ICON" + "HOME" "HOME_ICON" + "HOME_SUBFOLDER" "HOME_SUB_ICON" + ) + local current_state="DEFAULT" if [[ $(print -P "%~") == '~' ]]; then - "$1_prompt_segment" "$0_HOME" "$2" "blue" "$DEFAULT_COLOR" "$current_path" 'HOME_ICON' + current_state="HOME" elif [[ $(print -P "%~") == '~'* ]]; then - "$1_prompt_segment" "$0_HOME_SUBFOLDER" "$2" "blue" "$DEFAULT_COLOR" "$current_path" 'HOME_SUB_ICON' - else - "$1_prompt_segment" "$0_DEFAULT" "$2" "blue" "$DEFAULT_COLOR" "$current_path" 'FOLDER_ICON' + current_state="HOME_SUBFOLDER" fi + "$1_prompt_segment" "$0_${current_state}" "$2" "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}" } # Docker machine @@ -548,12 +557,12 @@ prompt_detect_virt() { if [[ "$virt" == "none" ]]; then if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then virt="chroot" - "$1_prompt_segment" "$0" "$2" "$color" "$virt" "" + "$1_prompt_segment" "$0" "$2" "$color" "$DEFAULT_COLOR" "$virt" else ; fi else - "$1_prompt_segment" "$0" "$2" "$color" "$virt" "" + "$1_prompt_segment" "$0" "$2" "$color" "$DEFAULT_COLOR" "$virt" fi } @@ -768,17 +777,16 @@ prompt_rvm() { # Status: return code if verbose, otherwise just an icon if an error occurred set_default POWERLEVEL9K_STATUS_VERBOSE true +set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false prompt_status() { - if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then - if [[ "$RETVAL" -ne 0 ]]; then + if [[ "$RETVAL" -ne 0 ]]; then + if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then "$1_prompt_segment" "$0_ERROR" "$2" "red" "226" "$RETVAL" 'CARRIAGE_RETURN_ICON' else - "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "046" "" 'OK_ICON' - fi - else - if [[ "$RETVAL" -ne 0 ]]; then "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' fi + elif [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then + "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "046" "" 'OK_ICON' fi } @@ -1111,4 +1119,3 @@ powerlevel9k_init() { } powerlevel9k_init "$@" - |