diff options
-rw-r--r-- | functions/icons.zsh | 6 | ||||
-rw-r--r-- | functions/utilities.zsh | 10 | ||||
-rwxr-xr-x | powerlevel9k.zsh-theme | 18 |
3 files changed, 28 insertions, 6 deletions
diff --git a/functions/icons.zsh b/functions/icons.zsh index 413ea19b..c2cdcba5 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -43,6 +43,7 @@ case $POWERLEVEL9K_MODE in MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' APPLE_ICON $'\uE26E' # FREEBSD_ICON $'\U1F608 ' # 😈 + ANDROID_ICON $'\uE270' # LINUX_ICON $'\uE271' # SUNOS_ICON $'\U1F31E ' # 🌞 HOME_ICON $'\uE12C' # @@ -112,6 +113,7 @@ case $POWERLEVEL9K_MODE in MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uF179' # FREEBSD_ICON $'\U1F608 ' # 😈 + ANDROID_ICON $'\uE17B' # LINUX_ICON $'\uF17C' # SUNOS_ICON $'\uF185 ' # HOME_ICON $'\uF015' # @@ -148,7 +150,7 @@ case $POWERLEVEL9K_MODE in SSH_ICON '(ssh)' ) ;; - 'nerdfont-fontconfig') + 'nerdfont-complete'|'nerdfont-fontconfig') # nerd-font patched (complete) font required! See # https://github.com/ryanoasis/nerd-fonts # Set the right locale to protect special characters @@ -177,6 +179,7 @@ case $POWERLEVEL9K_MODE in MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uF179' # FREEBSD_ICON $'\UF30E ' # + ANDROID_ICON $'\uF17B' # LINUX_ICON $'\uF17C' # SUNOS_ICON $'\uF185 ' # HOME_ICON $'\uF015' # @@ -242,6 +245,7 @@ case $POWERLEVEL9K_MODE in MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\u2500 ' APPLE_ICON 'OSX' FREEBSD_ICON 'BSD' + ANDROID_ICON 'And' LINUX_ICON 'Lx' SUNOS_ICON 'Sun' HOME_ICON '' diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 22b53c6a..86e5ba0e 100644 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -79,7 +79,7 @@ function getRelevantItem() { done } -# OS detection for the `os_icon` segment +# OS detection case $(uname) in Darwin) OS='OSX' @@ -100,6 +100,14 @@ case $(uname) in Linux) OS='Linux' OS_ICON=$(print_icon 'LINUX_ICON') + + # Check if we're running on Android + case $(uname -o 2>/dev/null) in + Android) + OS='Android' + OS_ICON=$(print_icon 'ANDROID_ICON') + ;; + esac ;; SunOS) OS='Solaris' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 1c4d338d..f6ab1225 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -425,12 +425,17 @@ prompt_battery() { esac fi - if [[ $OS =~ Linux ]]; then + if [[ "$OS" == 'Linux' ]] || [[ "$OS" == 'Android' ]]; then local sysp="/sys/class/power_supply" + # Reported BAT0 or BAT1 depending on kernel version [[ -a $sysp/BAT0 ]] && local bat=$sysp/BAT0 [[ -a $sysp/BAT1 ]] && local bat=$sysp/BAT1 + # Android-related + # Tested on: Moto G falcon (CM 13.0) + [[ -a $sysp/battery ]] && local bat=$sysp/battery + # Return if no battery found [[ -z $bat ]] && return local capacity=$(cat $bat/capacity) @@ -1008,7 +1013,7 @@ prompt_status() { "$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' + "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "green" "" 'OK_ICON' fi } @@ -1289,8 +1294,9 @@ powerlevel9k_prepare_prompts() { RETVAL=$? _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) + # Reset start time - _P9K_TIMER_START=99999999999 + _P9K_TIMER_START=0xFFFFFFFF if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then PROMPT="$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) @@ -1323,8 +1329,12 @@ NEWLINE=' } prompt_powerlevel9k_setup() { + # I decided to use the value below for better supporting 32-bit CPUs, since the previous value "99999999999" was causing issues on my Android phone, which is powered by an armv7l + # We don't have to change that until 19 January of 2038! :) + # Disable false display of command execution time - _P9K_TIMER_START=99999999999 + # Maximum integer on 32-bit CPUs + _P9K_TIMER_START=2147483647 # Display a warning if the terminal does not support 256 colors local term_colors |