mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-20 22:31:57 +00:00
add an option to enable/disable useless icons
This commit is contained in:
parent
bf5ad6d97a
commit
cdbbebf19d
1 changed files with 98 additions and 33 deletions
|
@ -1,9 +1,10 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt extended_glob noaliases
|
setopt noaliases
|
||||||
|
|
||||||
() {
|
() {
|
||||||
|
setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp}
|
||||||
|
|
||||||
typeset -g __p9k_root_dir
|
typeset -g __p9k_root_dir
|
||||||
typeset -gi force=0
|
typeset -gi force=0
|
||||||
|
@ -27,8 +28,15 @@ fi
|
||||||
|
|
||||||
source $__p9k_root_dir/internal/configure.zsh || return
|
source $__p9k_root_dir/internal/configure.zsh || return
|
||||||
|
|
||||||
|
typeset -ri prompt_indent=4
|
||||||
|
|
||||||
|
local POWERLEVEL9K_MODE style config_backup gap_char=' '
|
||||||
|
local -i num_lines write_config straight empty_line frame=1
|
||||||
|
local -i cap_diamond cap_python cap_narrow_icons cap_lock
|
||||||
|
local -a extra_icons=('' '')
|
||||||
|
|
||||||
typeset -ra lean_left=(
|
typeset -ra lean_left=(
|
||||||
'' '%B%39F~%b%31F/%B%39Fpowerlevel10k%b %76Fmaster ⇡2%f '
|
'' '%31F$extra_icons[1]%B%39F~%b%31F/%B%39Fpowerlevel10k%b %76F$extra_icons[2]master ⇡2%f '
|
||||||
'' '%76F❯%f █'
|
'' '%76F❯%f █'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -38,7 +46,7 @@ typeset -ra lean_right=(
|
||||||
)
|
)
|
||||||
|
|
||||||
typeset -ra classic_left=(
|
typeset -ra classic_left=(
|
||||||
'%240F╭─' '%K{236} %B%39F~%b%K{236}%31F/%B%39Fpowerlevel10k%b%K{236} %244F\uE0B1 %76Fmaster ⇡2 %k%236F\uE0B0%f'
|
'%240F╭─' '%K{236} %31F$extra_icons[1]%B%39F~%b%K{236}%31F/%B%39Fpowerlevel10k%b%K{236} %244F\uE0B1 %76F$extra_icons[2]master ⇡2 %k%236F\uE0B0%f'
|
||||||
'%240F╰─' '%f █'
|
'%240F╰─' '%f █'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,13 +55,8 @@ typeset -ra classic_right=(
|
||||||
'' '%240F─╯%f'
|
'' '%240F─╯%f'
|
||||||
)
|
)
|
||||||
|
|
||||||
typeset -ri prompt_indent=4
|
|
||||||
|
|
||||||
local POWERLEVEL9K_MODE style config_backup gap_char=' '
|
|
||||||
local -i num_lines write_config straight empty_line frame=1
|
|
||||||
local -i cap_diamond cap_python cap_narrow_icons cap_lock
|
|
||||||
|
|
||||||
function prompt_length() {
|
function prompt_length() {
|
||||||
|
# eval "1=\"$1\""
|
||||||
local COLUMNS=1024
|
local COLUMNS=1024
|
||||||
local -i x y=$#1 m
|
local -i x y=$#1 m
|
||||||
if (( y )); then
|
if (( y )); then
|
||||||
|
@ -75,6 +78,8 @@ function print_prompt() {
|
||||||
local right=${style}_right
|
local right=${style}_right
|
||||||
left=("${(@P)left}")
|
left=("${(@P)left}")
|
||||||
right=("${(@P)right}")
|
right=("${(@P)right}")
|
||||||
|
eval "left=(${(@)left:/(#b)(*)/\"$match[1]\"})"
|
||||||
|
eval "right=(${(@)right:/(#b)(*)/\"$match[1]\"})"
|
||||||
if (( num_lines == 1)); then
|
if (( num_lines == 1)); then
|
||||||
left=($left[2] $left[4])
|
left=($left[2] $left[4])
|
||||||
right=($right[1] $right[3])
|
right=($right[1] $right[3])
|
||||||
|
@ -298,6 +303,48 @@ function ask_style() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ask_extra_icons() {
|
||||||
|
if [[ $POWERLEVEL9K_MODE == (powerline|compatible) ]]; then
|
||||||
|
extra_icons=('' '')
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
local dir_icon=${(g::)icons[HOME_SUB_ICON]}
|
||||||
|
local vcs_icon=${(g::)icons[VCS_GIT_GITHUB_ICON]}
|
||||||
|
local branch_icon=${(g::)icons[VCS_BRANCH_ICON]}
|
||||||
|
if (( cap_narrow_icons )); then
|
||||||
|
dir_icon=${dir_icon// }
|
||||||
|
vcs_icon=${vcs_icon// }
|
||||||
|
branch_icon=${branch_icon// }
|
||||||
|
fi
|
||||||
|
local many=("$dir_icon " "$vcs_icon $branch_icon ")
|
||||||
|
while true; do
|
||||||
|
clear
|
||||||
|
centered "%BIcons%b"
|
||||||
|
print -P ""
|
||||||
|
print -P "%B(1) Few icons.%b"
|
||||||
|
print -P ""
|
||||||
|
extra_icons=('' '') print_prompt
|
||||||
|
print -P ""
|
||||||
|
print -P "%B(2) Many icons.%b"
|
||||||
|
print -P ""
|
||||||
|
extra_icons=("$many[@]") print_prompt
|
||||||
|
print -P ""
|
||||||
|
print -P "(r) Restart from the beginning."
|
||||||
|
print -P ""
|
||||||
|
print -P "(q) Quit and do nothing."
|
||||||
|
print -P ""
|
||||||
|
|
||||||
|
local key=
|
||||||
|
read -k key${(%):-"?%BChoice [12rq]: %b"} || return 1
|
||||||
|
case $key in
|
||||||
|
q) quit; return 1;;
|
||||||
|
r) return 2;;
|
||||||
|
1) extra_icons=('' ''); break;;
|
||||||
|
2) extra_icons=("$many[@]"); break;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
function ask_straight() {
|
function ask_straight() {
|
||||||
if [[ $style != classic || $cap_diamond == 0 ]]; then
|
if [[ $style != classic || $cap_diamond == 0 ]]; then
|
||||||
straight=1
|
straight=1
|
||||||
|
@ -307,11 +354,11 @@ function ask_straight() {
|
||||||
clear
|
clear
|
||||||
centered "%BPrompt Separators%b"
|
centered "%BPrompt Separators%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(1) Angled%b"
|
print -P "%B(1) Angled.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
straight=0 print_prompt
|
straight=0 print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(2) Straight%b"
|
print -P "%B(2) Straight.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
straight=1 print_prompt
|
straight=1 print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
|
@ -336,11 +383,11 @@ function ask_num_lines() {
|
||||||
clear
|
clear
|
||||||
centered "%BPrompt Height%b"
|
centered "%BPrompt Height%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(1) One line%b"
|
print -P "%B(1) One line.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
num_lines=1 print_prompt
|
num_lines=1 print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(2) Two lines%b"
|
print -P "%B(2) Two lines.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
num_lines=2 print_prompt
|
num_lines=2 print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
|
@ -368,15 +415,15 @@ function ask_gap_char() {
|
||||||
clear
|
clear
|
||||||
centered "%BPrompt Connection%b"
|
centered "%BPrompt Connection%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(1) Disconnected%b"
|
print -P "%B(1) Disconnected.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
gap_char=" " print_prompt
|
gap_char=" " print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(2) Dotted%b"
|
print -P "%B(2) Dotted.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
gap_char="·" print_prompt
|
gap_char="·" print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(3) Solid%b"
|
print -P "%B(3) Solid.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
gap_char="─" print_prompt
|
gap_char="─" print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
|
@ -406,15 +453,15 @@ function ask_frame() {
|
||||||
clear
|
clear
|
||||||
centered "%BPrompt Frame%b"
|
centered "%BPrompt Frame%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(1) No frame%b"
|
print -P "%B(1) No frame.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
frame=0 print_prompt
|
frame=0 print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(2) Only left%b"
|
print -P "%B(2) Only left.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
frame=1 print_prompt
|
frame=1 print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(3) Left and right%b"
|
print -P "%B(3) Left and right.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
frame=2 print_prompt
|
frame=2 print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
|
@ -438,12 +485,12 @@ function ask_empty_line() {
|
||||||
clear
|
clear
|
||||||
centered "%BPrompt Spacing%b"
|
centered "%BPrompt Spacing%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(1) Compact%b"
|
print -P "%B(1) Compact.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
print_prompt
|
print_prompt
|
||||||
print_prompt
|
print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
print -P "%B(2) Sparse%b"
|
print -P "%B(2) Sparse.%b"
|
||||||
print -P ""
|
print -P ""
|
||||||
print_prompt
|
print_prompt
|
||||||
print -P ""
|
print -P ""
|
||||||
|
@ -533,7 +580,7 @@ function generate_config() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function uncomment() {
|
function uncomment() {
|
||||||
lines=("${(@)lines/#(#b)([[:space:]]#)\# $1(|[[:space:]]*)/$match[1]$1${match[2]:= $match[2]}}")
|
lines=("${(@)lines/#(#b)([[:space:]]#)\# $1( |)/$match[1]$1$match[2]$match[2]}")
|
||||||
}
|
}
|
||||||
|
|
||||||
sub MODE $POWERLEVEL9K_MODE
|
sub MODE $POWERLEVEL9K_MODE
|
||||||
|
@ -551,6 +598,20 @@ function generate_config() {
|
||||||
sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'⇶'"
|
sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'⇶'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n ${(j::)extra_icons} ]]; then
|
||||||
|
local branch_icon=$icons[VCS_BRANCH_ICON]
|
||||||
|
(( cap_narrow_icons )) && branch_icon=${branch_icon// }
|
||||||
|
sub VCS_BRANCH_ICON "'$branch_icon '"
|
||||||
|
else
|
||||||
|
uncomment 'typeset -g POWERLEVEL9K_DIR_CLASSES'
|
||||||
|
uncomment 'typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION'
|
||||||
|
uncomment 'typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION'
|
||||||
|
uncomment 'typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION'
|
||||||
|
sub VCS_VISUAL_IDENTIFIER_EXPANSION ''
|
||||||
|
sub COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION ''
|
||||||
|
sub TIME_VISUAL_IDENTIFIER_EXPANSION ''
|
||||||
|
fi
|
||||||
|
|
||||||
if (( straight )); then
|
if (( straight )); then
|
||||||
[[ $POWERLEVEL9K_MODE == nerdfont-complete ]] && local subsep='\uE0BD' || local subsep='|'
|
[[ $POWERLEVEL9K_MODE == nerdfont-complete ]] && local subsep='\uE0BD' || local subsep='|'
|
||||||
sub LEFT_SUBSEGMENT_SEPARATOR "'%244F$subsep'"
|
sub LEFT_SUBSEGMENT_SEPARATOR "'%244F$subsep'"
|
||||||
|
@ -572,7 +633,7 @@ function generate_config() {
|
||||||
|
|
||||||
sub MULTILINE_FIRST_PROMPT_GAP_CHAR "'$gap_char'"
|
sub MULTILINE_FIRST_PROMPT_GAP_CHAR "'$gap_char'"
|
||||||
|
|
||||||
if (( frame < 2 )); then
|
if (( num_lines == 2 && frame < 2 )); then
|
||||||
sub MULTILINE_FIRST_PROMPT_SUFFIX ''
|
sub MULTILINE_FIRST_PROMPT_SUFFIX ''
|
||||||
sub MULTILINE_NEWLINE_PROMPT_SUFFIX ''
|
sub MULTILINE_NEWLINE_PROMPT_SUFFIX ''
|
||||||
sub MULTILINE_LAST_PROMPT_SUFFIX ''
|
sub MULTILINE_LAST_PROMPT_SUFFIX ''
|
||||||
|
@ -599,10 +660,12 @@ function generate_config() {
|
||||||
header+=$'.\n'
|
header+=$'.\n'
|
||||||
header+="# Wizard options: $POWERLEVEL9K_MODE"
|
header+="# Wizard options: $POWERLEVEL9K_MODE"
|
||||||
(( cap_narrow_icons )) && header+=", small icons" || header+=", big icons"
|
(( cap_narrow_icons )) && header+=", small icons" || header+=", big icons"
|
||||||
|
[[ -n ${(j::)extra_icons} ]] && header+=", many icons" || header+=", few icons"
|
||||||
if [[ $style == classic ]]; then
|
if [[ $style == classic ]]; then
|
||||||
(( straight )) && header+=", straight" || header+=", angled"
|
(( straight )) && header+=", straight" || header+=", angled"
|
||||||
fi
|
fi
|
||||||
(( num_lines == 1 )) && header+=", 1 line" || header+=", $num_lines lines"
|
(( num_lines == 1 )) && header+=", 1 line" || header+=", $num_lines lines"
|
||||||
|
if (( num_lines == 2 )); then
|
||||||
case $gap_char in
|
case $gap_char in
|
||||||
' ') header+=", disconnected";;
|
' ') header+=", disconnected";;
|
||||||
'·') header+=", dotted";;
|
'·') header+=", dotted";;
|
||||||
|
@ -613,6 +676,7 @@ function generate_config() {
|
||||||
1) header+=", left frame";;
|
1) header+=", left frame";;
|
||||||
2) header+=", full frame";;
|
2) header+=", full frame";;
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
(( empty_line )) && header+=", sparse" || header+=", compact";
|
(( empty_line )) && header+=", sparse" || header+=", compact";
|
||||||
header+=$'.\n#'
|
header+=$'.\n#'
|
||||||
|
|
||||||
|
@ -677,6 +741,7 @@ while true; do
|
||||||
_p9k_init_icons
|
_p9k_init_icons
|
||||||
ask_narrow_icons || { (( $? == 2 )) && continue || return }
|
ask_narrow_icons || { (( $? == 2 )) && continue || return }
|
||||||
ask_style || { (( $? == 2 )) && continue || return }
|
ask_style || { (( $? == 2 )) && continue || return }
|
||||||
|
ask_extra_icons || { (( $? == 2 )) && continue || return }
|
||||||
ask_straight || { (( $? == 2 )) && continue || return }
|
ask_straight || { (( $? == 2 )) && continue || return }
|
||||||
ask_num_lines || { (( $? == 2 )) && continue || return }
|
ask_num_lines || { (( $? == 2 )) && continue || return }
|
||||||
ask_gap_char || { (( $? == 2 )) && continue || return }
|
ask_gap_char || { (( $? == 2 )) && continue || return }
|
||||||
|
|
Loading…
Reference in a new issue