diff options
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index ef6d0a5a..2b4f0dbd 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -360,7 +360,7 @@ prompt_battery() { local time_remaining=$(echo $raw_data | grep TimeRemaining | awk '{ print $5 }') if [[ -n $time_remaining ]]; then # this value is set to a very high number when the system is calculating - [[ $time_remaining -gt 10000 ]] && local tstring="..." || local tstring=${(f)$(date -u -r $(($time_remaining * 60)) +%k:%M)} + [[ $time_remaining -gt 10000 ]] && local tstring="..." || local tstring=${(f)$(/bin/date -u -r $(($time_remaining * 60)) +%k:%M)} fi # Get charge values @@ -445,8 +445,11 @@ prompt_context() { # the output in a segment. prompt_custom() { local command=POWERLEVEL9K_CUSTOM_$3:u + local segment_content="$(eval ${(P)command})" - "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$(eval ${(P)command})" + if [[ -n $segment_content ]]; then + "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" + fi } # Dir: current working directory @@ -1049,13 +1052,23 @@ powerlevel9k_init() { # Display a warning if the terminal does not support 256 colors local term_colors term_colors=$(echotc Co) - if (( term_colors < 256 )); then + if (( $term_colors < 256 )); then print -P "%F{red}WARNING!%f Your terminal appears to support less than 256 colors!" print -P "If your terminal supports 256 colors, please export the appropriate environment variable" print -P "_before_ loading this theme in your \~\/.zshrc. In most terminal emulators, putting" print -P "%F{blue}export TERM=\"xterm-256color\"%f at the top of your \~\/.zshrc is sufficient." fi + # If the terminal `LANG` is set to `C`, this theme will not work at all. + local term_lang + term_lang=$(echo $LANG) + if [[ $term_lang == 'C' ]]; then + print -P "\t%F{red}WARNING!%f Your terminal's 'LANG' is set to 'C', which breaks this theme!" + print -P "\t%F{red}WARNING!%f Please set your 'LANG' to a UTF-8 language, like 'en_US.UTF-8'" + print -P "\t%F{red}WARNING!%f _before_ loading this theme in your \~\.zshrc. Putting" + print -P "\t%F{red}WARNING!%f %F{blue}export LANG=\"en_US.UTF-8\"%f at the top of your \~\/.zshrc is sufficient." + fi + # Display a warning if deprecated segments are in use. typeset -AH deprecated_segments # old => new @@ -1085,3 +1098,4 @@ powerlevel9k_init() { } powerlevel9k_init "$@" + |