1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-22 04:10:07 +00:00

add the default powerlevel9k style to the wizard

This commit is contained in:
romkatv 2019-10-10 17:36:40 +02:00
parent 640d513554
commit 0c59d87f08
2 changed files with 141 additions and 12 deletions

74
config/p10k-p9k.zsh Normal file
View file

@ -0,0 +1,74 @@
# Config for Powerlevel10k with the default style of Powerlevel9k.
# Temporarily change options.
'builtin' 'local' '-a' 'p10k_config_opts'
[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases')
[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob')
[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand')
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
() {
emulate -L zsh
# Unset all configuration options. This allows you to apply configiguration changes without
# restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`.
unset -m 'POWERLEVEL9K_*'
# To disable default icons for all segments, set POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION=''.
#
# To enable default icons for all segments, don't define POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION
# or set it to '${P9K_VISUAL_IDENTIFIER}'.
#
# To remove trailing space from all default icons, set POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION
# to '${P9K_VISUAL_IDENTIFIER% }'.
#
# To enable default icons for one segment (e.g., dir), set
# POWERLEVEL9K_DIR_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}'.
#
# To assign a specific icon to one segment (e.g., dir), set
# POWERLEVEL9K_DIR_VISUAL_IDENTIFIER_EXPANSION='⭐'.
#
# To assign a specific icon to a segment in a given state (e.g., dir in state NOT_WRITABLE),
# set POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'.
#
# Note: You can use $'\u2B50' instead of '⭐'. It's especially convenient when specifying
# icons that your text editor cannot render. Don't forget to put $ and use single quotes when
# defining icons via Unicode codepoints.
#
# Note: Many default icons cannot be displayed with system fonts. You'll need to install a
# capable font to use them. See POWERLEVEL9K_MODE below.
# typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}'
# This option makes a difference only when default icons are enabled for all or some prompt
# segments (see POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION above). LOCK_ICON can be printed as
# $'\uE0A2', $'\uE138' or $'\uF023' depending on POWERLEVEL9K_MODE. The correct value of this
# parameter depends on the provider of the font your terminal is using.
#
# Font Provider | POWERLEVEL9K_MODE
# ---------------------------------+-------------------
# Powerline | powerline
# Font Awesome | awesome-fontconfig
# Adobe Source Code Pro | awesome-fontconfig
# Source Code Pro | awesome-fontconfig
# Awesome-Terminal Fonts (regular) | awesome-fontconfig
# Awesome-Terminal Fonts (patched) | awesome-patched
# Nerd Fonts | nerdfont-complete
# Other | compatible
#
# If this looks overwhelming, either stick with a preinstalled system font and set
# POWERLEVEL9K_MODE=compatible, or install the recommended Powerlevel10k font from
# https://github.com/romkatv/powerlevel10k/#recommended-meslo-nerd-font-patched-for-powerlevel10k
# and set POWERLEVEL9K_MODE=nerdfont-complete.
typeset -g POWERLEVEL9K_MODE=nerdfont-complete
# typeset -g POWERLEVEL9K_PYTHON_ICON=
# typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON=
# typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON=
# typeset -g POWERLEVEL9K_VCS_STAGED_ICON=
# typeset -g POWERLEVEL9K_VCS_STASH_ICON=
# typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON=
# typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON=
}
(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]}
'builtin' 'unset' 'p10k_config_opts'

View file

@ -90,6 +90,16 @@ typeset -ra pure_right=(
'' '' '' ''
) )
typeset -ra p9k_left=(
'' '%K{0}%F{3} user@host %K{4}%F{0}$right_triangle%F{0} $extra_icons[2]~/src %K{2}%F{4}$right_triangle%F{0} $extra_icons[3]master %k%F{2}$right_triangle%f'
'' ' █'
)
typeset -ra p9k_right=(
'%F{0}$left_triangle%K{0}%F{2} ${(g::)icons[OK_ICON]} %F{8}$left_triangle%K{8}%F{0} 42 %F{7}$left_triangle%K{7}%F{0} 16:23:42 $extra_icons[5]%k%f' ''
'' ''
)
function prompt_length() { function prompt_length() {
local COLUMNS=1024 local COLUMNS=1024
local -i x y=$#1 m local -i x y=$#1 m
@ -529,34 +539,67 @@ function ask_narrow_icons() {
} }
function ask_style() { function ask_style() {
if (( cap_diamond && LINES < 25 )); then
local nl=''
else
local nl=$'\n'
fi
while true; do while true; do
clear clear
local extra=
flowing -c "%BPrompt Style%b" flowing -c "%BPrompt Style%b"
print -P "" print -n $nl
print -P "%B(1) Lean.%b" print -P "%B(1) Lean (recommended).%b"
print -P "" print -n $nl
style=lean print_prompt style=lean print_prompt
print -P "" print -P ""
print -P "%B(2) Classic.%b" print -P "%B(2) Classic (recommended).%b"
print -P "" print -n $nl
style=classic print_prompt style=classic print_prompt
print -P "" print -P ""
print -P "%B(3) Pure.%b" print -P "%B(3) Pure.%b"
print -P "" print -n $nl
style=pure print_prompt style=pure print_prompt
print -P "" print -P ""
if (( cap_diamond )); then
extra+=4
print -P "%B(4) Powerlevel9k.%b"
print -P ""
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]}
local time_icon=${(g::)icons[TIME_ICON]}
if (( cap_narrow_icons )); then
dir_icon=${dir_icon// }
vcs_icon=${vcs_icon// }
duration_icon=${duration_icon// }
time_icon=${time_icon// }
fi
branch_icon=${branch_icon// }
local many_icons=("" "$dir_icon " "$vcs_icon $branch_icon " " " "$time_icon ")
extra_icons=("$many_icons[@]") style=p9k num_lines=1 print_prompt
print -P ""
fi
print -P "(r) Restart from the beginning." print -P "(r) Restart from the beginning."
print -P "(q) Quit and do nothing." print -P "(q) Quit and do nothing."
print -P "" print -P ""
local key= local key=
read -k key${(%):-"?%BChoice [123rq]: %b"} || quit -c read -k key${(%):-"?%BChoice [123${extra}rq]: %b"} || quit -c
case $key in case $key in
q) quit;; q) quit;;
r) return 1;; r) return 1;;
1) style=lean; options+=lean; break;; 1) style=lean; options+=lean; break;;
2) style=classic; options+=classic; break;; 2) style=classic; options+=classic; break;;
3) style=pure; options+=pure; break;; 3) style=pure; empty_line=1; options+=pure; break;;
4) if [[ $extra == *4* ]]; then
style=p9k
num_lines=1
extra_icons=("$many_icons[@]")
options+=p9k
break
fi
;;
esac esac
done done
} }
@ -1231,9 +1274,22 @@ function generate_config() {
sub MODE $POWERLEVEL9K_MODE sub MODE $POWERLEVEL9K_MODE
if (( cap_narrow_icons )); then if (( cap_narrow_icons )); then
uncomment 'typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION'
sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'"
sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'"
sub OS_ICON_CONTENT_EXPANSION "'%B\${P9K_CONTENT// }'" sub OS_ICON_CONTENT_EXPANSION "'%B\${P9K_CONTENT// }'"
uncomment 'typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON'
uncomment 'typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON'
uncomment 'typeset -g POWERLEVEL9K_VCS_STAGED_ICON'
uncomment 'typeset -g POWERLEVEL9K_VCS_STASH_ICON'
uncomment 'typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON'
uncomment 'typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON'
sub VCS_UNTRACKED_ICON "'${icons[VCS_UNTRACKED_ICON]// }'"
sub VCS_UNSTAGED_ICON "'${icons[VCS_UNSTAGED_ICON]// }'"
sub VCS_STAGED_ICON "'${icons[VCS_STAGED_ICON]// }'"
sub VCS_STASH_ICON "'${icons[VCS_STASH_ICON]// }'"
sub VCS_INCOMING_CHANGES_ICON "'${icons[VCS_INCOMING_CHANGES_ICON]// }'"
sub VCS_OUTGOING_CHANGES_ICON "'${icons[VCS_OUTGOING_CHANGES_ICON]// }'"
else else
sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'"
sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'"
@ -1250,9 +1306,11 @@ function generate_config() {
uncomment 'typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION' uncomment 'typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION'
uncomment 'typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION' uncomment 'typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION'
uncomment 'typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION' uncomment 'typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION'
uncomment 'typeset -g POWERLEVEL9K_PYTHON_ICON'
sub VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION "'🐍'" sub VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION "'🐍'"
sub ANACONDA_VISUAL_IDENTIFIER_EXPANSION "'🐍'" sub ANACONDA_VISUAL_IDENTIFIER_EXPANSION "'🐍'"
sub PYENV_VISUAL_IDENTIFIER_EXPANSION "'🐍'" sub PYENV_VISUAL_IDENTIFIER_EXPANSION "'🐍'"
sub PYTHON_ICON "'🐍'"
fi fi
if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then
@ -1467,10 +1525,7 @@ while true; do
_p9k_init_icons _p9k_init_icons
ask_narrow_icons || continue ask_narrow_icons || continue
ask_style || continue ask_style || continue
if [[ $style == pure ]]; then if [[ $style == (lean|classic) ]]; then
empty_line=1
options+='sparse'
else
ask_color || continue ask_color || continue
ask_time || continue ask_time || continue
ask_separators || continue ask_separators || continue