mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-12 19:18:28 +02:00
make gap between left and right prompt customizable
This commit is contained in:
parent
f16b29502c
commit
5dd3ecab5f
@ -111,15 +111,36 @@ fi
|
||||
typeset -g POWERLEVEL9K_MODE=nerdfont-complete
|
||||
|
||||
# Add an empty line before each prompt. If you set it to false, you might want to
|
||||
# set POWERLEVEL9K_SHOW_RULER to true below.
|
||||
# set POWERLEVEL9K_SHOW_RULER=true or POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR='·' below.
|
||||
typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
|
||||
|
||||
# Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll
|
||||
# probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE to false above.
|
||||
# probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and
|
||||
# POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below.
|
||||
typeset -g POWERLEVEL9K_SHOW_RULER=false
|
||||
typeset -g POWERLEVEL9K_RULER_CHAR='─'
|
||||
typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '·'
|
||||
typeset -g POWERLEVEL9K_RULER_FOREGROUND=237
|
||||
|
||||
# Filler between left and right prompt on the first prompt line. You can set it to '·' or '─'
|
||||
# to make it easier to see the alignment between left and right prompt and to separate prompt
|
||||
# from command output. It serves the same purpose as ruler (see above) without increasing
|
||||
# the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false
|
||||
# if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact
|
||||
# prompt.
|
||||
typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' '
|
||||
if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then
|
||||
# The color of the filler.
|
||||
typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=237
|
||||
# Add a space between the end of left prompt and the filler.
|
||||
typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' '
|
||||
# Add a space between the filler and the start of right prompt.
|
||||
typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' '
|
||||
# Start filler from the edge of the screen if there are no left segments on the first line.
|
||||
typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}'
|
||||
# End filler on the edge of the screen if there are no right segments on the first line.
|
||||
typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}'
|
||||
fi
|
||||
|
||||
# OS identifier color.
|
||||
typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=212
|
||||
# Want to display a different icon? Uncomment the next line and set the desired value.
|
||||
@ -135,6 +156,7 @@ fi
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮'
|
||||
# Prompt symbol in visual vi mode.
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='Ⅴ'
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=''
|
||||
|
||||
# Enable special styling for non-writable directories. If set to false,
|
||||
# POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION defined below won't have effect.
|
||||
|
@ -2773,7 +2773,7 @@ function _p9k_set_prompt() {
|
||||
else
|
||||
PROMPT+='${_P9K_LPROMPT}'
|
||||
fi
|
||||
((i != num_lines && $#right)) && PROMPT+=$_P9K_GAP_POST
|
||||
((i != num_lines && $#right)) && PROMPT+=$_P9K_LINE_GAP_POST[i]
|
||||
else
|
||||
PROMPT+=$_P9K_PROMPT
|
||||
fi
|
||||
@ -3065,8 +3065,31 @@ prompt__p9k_internal_nothing() {
|
||||
_P9K_PROMPT+='${_P9K_SSS::=}'
|
||||
}
|
||||
|
||||
# _p9k_build_gap_post <first|newline>
|
||||
_p9k_build_gap_post() {
|
||||
_p9k_get_icon '' MULTILINE_${(U)1}_PROMPT_GAP_CHAR
|
||||
local char=${_P9K_RETVAL:- }
|
||||
_p9k_prompt_length $char
|
||||
if (( _P9K_RETVAL != 1 || $#char != 1 )); then
|
||||
print -P "%F{red}WARNING!%f %BMULTILINE_{(U)1}_PROMPT_GAP_CHAR%b is not one character long. Will use ' '."
|
||||
print -P "Either change the value of %BPOWERLEVEL9K_MULTILINE_{(U)1}_PROMPT_GAP_CHAR%b or remove it."
|
||||
char=' '
|
||||
fi
|
||||
local style
|
||||
_p9k_color prompt_multiline_$1_prompt_gap BACKGROUND ""
|
||||
_p9k_background $_P9K_RETVAL
|
||||
style+=$_P9K_RETVAL
|
||||
_p9k_color prompt_multiline_$1_prompt_gap FOREGROUND ""
|
||||
_p9k_foreground $_P9K_RETVAL
|
||||
style+=$_P9K_RETVAL
|
||||
[[ $char == '.' ]] && local s=',' || local s='.'
|
||||
_P9K_RETVAL=$style'${${${_P9K_M:#-*}:+${(pl'$s'$((_P9K_M+1))'$s$s$char$s$')}$_P9K_RPROMPT$_P9K_T[$((1+!_P9K_IND))]}:-\n}'
|
||||
[[ -n $style ]] && _P9K_RETVAL+='%b%k%f'
|
||||
}
|
||||
|
||||
_p9k_init_lines() {
|
||||
typeset -ga _P9K_LINE_{SEGMENTS,PREFIX,SUFFIX}_{LEFT,RIGHT} _P9K_LINE_NEVER_EMPTY_RIGHT
|
||||
typeset -ga _P9K_LINE_{SEGMENTS,PREFIX,SUFFIX}_{LEFT,RIGHT}
|
||||
typeset -ga _P9K_LINE_NEVER_EMPTY_RIGHT _P9K_LINE_GAP_POST
|
||||
local -a left_segments=($POWERLEVEL9K_LEFT_PROMPT_ELEMENTS)
|
||||
local -a right_segments=($POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS)
|
||||
|
||||
@ -3120,6 +3143,9 @@ _p9k_init_lines() {
|
||||
fi
|
||||
|
||||
if (( num_lines > 1 )); then
|
||||
_p9k_build_gap_post first
|
||||
_P9K_LINE_GAP_POST[1]=$_P9K_RETVAL
|
||||
|
||||
if [[ $+POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX == 1 || $POWERLEVEL9K_PROMPT_ON_NEWLINE == true ]]; then
|
||||
# Not escaped for historical reasons.
|
||||
_p9k_get_icon '' MULTILINE_FIRST_PROMPT_PREFIX
|
||||
@ -3151,6 +3177,9 @@ _p9k_init_lines() {
|
||||
fi
|
||||
|
||||
if (( num_lines > 2 )); then
|
||||
_p9k_build_gap_post newline
|
||||
_P9K_LINE_GAP_POST[2,-2]=(${${:-{3..num_lines}}:/*/$_P9K_RETVAL})
|
||||
|
||||
if [[ $+POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX == 1 || $POWERLEVEL9K_PROMPT_ON_NEWLINE == true ]]; then
|
||||
# Not escaped for historical reasons.
|
||||
_p9k_get_icon '' MULTILINE_NEWLINE_PROMPT_PREFIX
|
||||
@ -3184,8 +3213,6 @@ _p9k_init_prompt() {
|
||||
_P9K_GAP_PRE+='${_P9K_M::=$((_P9K_CLM-_P9K_X-_P9K_IND-1))}'
|
||||
_P9K_GAP_PRE+='}+}'
|
||||
|
||||
typeset -g _P9K_GAP_POST=$'${${${_P9K_M:#-*}:+${(pl.$((_P9K_M+1)).. .)}$_P9K_RPROMPT$_P9K_T[$((1+!_P9K_IND))]}:-\n}'
|
||||
|
||||
typeset -g _P9K_PROMPT_PREFIX_LEFT='${${_P9K_CLM::=$COLUMNS}+}${${COLUMNS::=1024}+}'
|
||||
typeset -g _P9K_PROMPT_PREFIX_RIGHT='${${_P9K_CLM::=$COLUMNS}+}${${COLUMNS::=1024}+}'
|
||||
typeset -g _P9K_PROMPT_SUFFIX_LEFT='${${COLUMNS::=$_P9K_CLM}+}'
|
||||
|
Loading…
Reference in New Issue
Block a user