diff options
author | romkatv <roman.perepelitsa@gmail.com> | 2019-05-28 16:16:27 +0300 |
---|---|---|
committer | romkatv <roman.perepelitsa@gmail.com> | 2019-05-28 16:16:27 +0300 |
commit | 4e3ec4850cbadd7b744cb4110b4f17b3ab717949 (patch) | |
tree | f5c4924121e3b8dd7dcac32fcb3d58a455ce9a3b /powerlevel9k.zsh-theme | |
parent | 2e4235cffa69b2200f0f516787bbdf7115f8c664 (diff) |
new feature: ruler above the prompt; to enable: POWERLEVEL9K_SHOW_RULER=true
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 4e1bfb77..9d350fea 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -2202,6 +2202,7 @@ function _p9k_update_prompt() { typeset -gi _P9K_REGION_ACTIVE set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false +set_default POWERLEVEL9K_SHOW_RULER false powerlevel9k_refresh_prompt_inplace() { emulate -L zsh @@ -2439,6 +2440,34 @@ _p9k_init() { done _P9K_ALIGNED_RPROMPT+='$_P9K_RPROMPT' + if [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]]; then + repeat ${POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT:-1} _P9K_LEFT_PREFIX+=$'\n' + fi + + if [[ $POWERLEVEL9K_SHOW_RULER == true ]]; then + _p9k_get_icon RULER_CHAR + local ruler_char=$_P9K_RETVAL + _p9k_prompt_length $ruler_char + if (( _P9K_RETVAL == 1 && $#ruler_char == 1 )); then + _p9k_color "" prompt_ruler BACKGROUND + _p9k_background $_P9K_RETVAL + _P9K_LEFT_PREFIX+=$_P9K_RETVAL + _p9k_color "" prompt_ruler FOREGROUND + _p9k_foreground $_P9K_RETVAL + _P9K_LEFT_PREFIX+=$_P9K_RETVAL + [[ $ruler_char == '.' ]] && local sep=',' || local sep='.' + local indent='${${ZLE_RPROMPT_INDENT:-1}/#-*/0}' + local ruler_len="\${\$((COLUMNS-$indent))/#-*/0}" + local pad_len="\$((COLUMNS-$ruler_len))" + _P9K_LEFT_PREFIX+="%b\${(pl$sep$ruler_len$sep$sep${(q)ruler_char}$sep)}%k%f" + _P9K_LEFT_PREFIX+="\${(l$sep$pad_len$sep$sep $sep)}" + fi + fi + + if [[ $ITERM_SHELL_INTEGRATION_INSTALLED == Yes ]]; then + _P9K_LEFT_PREFIX+="%{$(iterm2_prompt_mark)%}" + fi + _P9K_LEFT_PREFIX+='${${_P9K_BG::=NONE}+}${${_P9K_I::=0}+}' _P9K_RIGHT_PREFIX+='${${_P9K_BG::=NONE}+}${${_P9K_I::=0}+}' @@ -2471,14 +2500,6 @@ _p9k_init() { _P9K_LEFT_PREFIX+="%f%b%k" fi - if [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]]; then - repeat ${POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT:-1} { _P9K_LEFT_PREFIX=$'\n'$_P9K_LEFT_PREFIX } - fi - - if [[ $ITERM_SHELL_INTEGRATION_INSTALLED == Yes ]]; then - _P9K_LEFT_PREFIX="%{$(iterm2_prompt_mark)%}$_P9K_LEFT_PREFIX" - fi - # If the terminal `LANG` is set to `C`, this theme will not work at all. if [[ $LANG == "C" && $POWERLEVEL9K_IGNORE_TERM_LANG == false ]]; then print -P "\t%F{red}WARNING!%f Your terminal's 'LANG' is set to 'C', which breaks this theme!" |