diff options
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index cfb34292..4d8d1c39 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) @@ -613,6 +618,7 @@ prompt_command_execution_time() { # Dir: current working directory set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" +set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" prompt_dir() { local current_path="$(print -P "%~")" if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" ]]; then @@ -664,7 +670,7 @@ prompt_dir() { break; fi done - + local packageName=$(jq '.name' ${pkgFile} 2> /dev/null \ || node -e 'console.log(require(process.argv[1]).name);' ${pkgFile} 2>/dev/null \ || cat "${pkgFile}" 2> /dev/null | grep -m 1 "\"name\"" | awk -F ':' '{print $2}' | awk -F '"' '{print $2}' 2>/dev/null \ @@ -717,6 +723,10 @@ prompt_dir() { current_path="$( echo "${current_path}" | sed "s/\//${POWERLEVEL9K_DIR_PATH_SEPARATOR}/g")" fi + if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" ]]; then + current_path="$( echo "${current_path}" | sed "s/^~/${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}/")" + fi + typeset -AH dir_states dir_states=( "DEFAULT" "FOLDER_ICON" @@ -1140,6 +1150,12 @@ powerlevel9k_vcs_init() { zstyle ':vcs_info:hg*:*' get-bookmarks true zstyle ':vcs_info:hg*+gen-hg-bookmark-string:*' hooks hg-bookmarks + # For svn, only + # TODO fix the %b (branch) format for svn. Using %b breaks + # color-encoding of the foreground for the rest of the powerline. + zstyle ':vcs_info:svn*:*' formats "$VCS_CHANGESET_PREFIX%c%u" + zstyle ':vcs_info:svn*:*' actionformats "$VCS_CHANGESET_PREFIX%c%u %F{${POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" + if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then zstyle ':vcs_info:*' get-revision true fi @@ -1278,12 +1294,13 @@ 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) -$(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')" + PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) +$(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')' if [[ "$POWERLEVEL9K_RPROMPT_ON_NEWLINE" != true ]]; then # The right prompt should be on the same line as the first line of the left # prompt. To do so, there is just a quite ugly workaround: Before zsh draws @@ -1298,13 +1315,13 @@ $(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')" RPROMPT_SUFFIX='' fi else - PROMPT="%f%b%k$(build_left_prompt)" + PROMPT='%f%b%k$(build_left_prompt)' RPROMPT_PREFIX='' RPROMPT_SUFFIX='' fi if [[ "$POWERLEVEL9K_DISABLE_RPROMPT" != true ]]; then - RPROMPT="$RPROMPT_PREFIX%f%b%k$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX" + RPROMPT='$RPROMPT_PREFIX%f%b%k$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX' fi NEWLINE=' ' @@ -1312,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 |