Merge pull request #173 from dritter/consistent_visual_identifier

Better support for segments that are just icons.
pull/22/head
Ben Hilburn 9 years ago
commit c39c8cbb99

@ -178,7 +178,11 @@ left_prompt_segment() {
fi fi
fi fi
[[ -n "$5" ]] && echo -n "${visual_identifier}%{$fg%}${5}${POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}" # Print the visual identifier
echo -n "${visual_identifier}"
# Print the content of the segment, if there is any
[[ -n "$5" ]] && echo -n "%{$fg%}${5}"
echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}"
CURRENT_BG=$3 CURRENT_BG=$3
} }
@ -256,8 +260,10 @@ right_prompt_segment() {
# Print whitespace only if segment is not joined or first right segment # Print whitespace only if segment is not joined or first right segment
[[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]] && echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]] && echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}"
# Print segment content # Print segment content if there is any
[[ -n "$5" ]] && echo -n "${5}${visual_identifier}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" [[ -n "$5" ]] && echo -n "${5}"
# Print the visual identifier
echo -n "${visual_identifier}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f"
CURRENT_RIGHT_BG=$3 CURRENT_RIGHT_BG=$3
} }
@ -292,7 +298,7 @@ prompt_custom() {
# print an icon, if there are background jobs # print an icon, if there are background jobs
prompt_background_jobs() { prompt_background_jobs() {
if [[ $(jobs -l | wc -l) -gt 0 ]]; then if [[ $(jobs -l | wc -l) -gt 0 ]]; then
"$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "cyan" "$(print_icon 'BACKGROUND_JOBS_ICON')" "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "cyan" "" 'BACKGROUND_JOBS_ICON'
fi fi
} }
@ -598,7 +604,7 @@ prompt_rbenv() {
# print an icon if user is root. # print an icon if user is root.
prompt_root_indicator() { prompt_root_indicator() {
if [[ "$UID" -eq 0 ]]; then if [[ "$UID" -eq 0 ]]; then
"$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$(print_icon 'ROOT_ICON')" "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON'
fi fi
} }
@ -639,13 +645,13 @@ set_default POWERLEVEL9K_STATUS_VERBOSE true
prompt_status() { prompt_status() {
if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then
if [[ "$RETVAL" -ne 0 ]]; then if [[ "$RETVAL" -ne 0 ]]; then
"$1_prompt_segment" "$0_ERROR" "$2" "red" "226" "$RETVAL $(print_icon 'CARRIAGE_RETURN_ICON')" "$1_prompt_segment" "$0_ERROR" "$2" "red" "226" "$RETVAL" 'CARRIAGE_RETURN_ICON'
else else
"$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "046" "$(print_icon 'OK_ICON')" "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "046" "" 'OK_ICON'
fi fi
else else
if [[ "$RETVAL" -ne 0 ]]; then if [[ "$RETVAL" -ne 0 ]]; then
"$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "$(print_icon 'FAIL_ICON')" "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON'
fi fi
fi fi
} }

Loading…
Cancel
Save