1
0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-02 02:56:36 +02:00

new feature: ruler above the prompt; to enable: POWERLEVEL9K_SHOW_RULER=true

This commit is contained in:
romkatv 2019-05-28 15:16:27 +02:00
parent 2e4235cffa
commit 4e3ec4850c
2 changed files with 34 additions and 8 deletions

View File

@ -30,6 +30,7 @@ function _p9k_init_icons() {
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons=(
RULER_CHAR $'\u2500' # ─
LEFT_SEGMENT_SEPARATOR $'\uE0B0' # 
RIGHT_SEGMENT_SEPARATOR $'\uE0B2' # 
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
@ -132,6 +133,7 @@ function _p9k_init_icons() {
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons=(
RULER_CHAR $'\u2500' # ─
LEFT_SEGMENT_SEPARATOR $'\uE0B0' # 
RIGHT_SEGMENT_SEPARATOR $'\uE0B2' # 
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
@ -239,6 +241,7 @@ function _p9k_init_icons() {
fi
icons=(
RULER_CHAR $'\u2500' # ─
LEFT_SEGMENT_SEPARATOR $'\uE0B0' # 
RIGHT_SEGMENT_SEPARATOR $'\uE0B2' # 
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
@ -334,6 +337,7 @@ function _p9k_init_icons() {
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons=(
RULER_CHAR $'\u2500' # ─
LEFT_SEGMENT_SEPARATOR $'\uE0B0' # 
RIGHT_SEGMENT_SEPARATOR $'\uE0B2' # 
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
@ -432,6 +436,7 @@ function _p9k_init_icons() {
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons=(
RULER_CHAR $'\u2500' # ─
LEFT_SEGMENT_SEPARATOR $'\uE0B0' # 
RIGHT_SEGMENT_SEPARATOR $'\uE0B2' # 
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace

View File

@ -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!"