mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-14 00:50:08 +00:00
wizard: encode generation source and options
This commit is contained in:
parent
ef57656e88
commit
1731b69f5f
1 changed files with 22 additions and 11 deletions
|
@ -180,19 +180,19 @@ function _p9k_ask_style() {
|
|||
_p9k_clear
|
||||
print -P " %BChoose your prompt style%b"
|
||||
print -P ""
|
||||
print -P " %B%3FLean%f%b"
|
||||
print -P " %BLean%b"
|
||||
print -P ""
|
||||
print -P " %B%39F~%b%12F/%B%39Fpowerlevel10k%b %76Fmaster ⇡2%f"
|
||||
print -P " %76F❯%f █"
|
||||
print -P ""
|
||||
print -P " %B%3FClassic%f%b"
|
||||
print -P " %BClassic%b"
|
||||
print -P ""
|
||||
print -P " %8F╭─%K{0} %B%39F~%b%K{0}%12F/%B%39Fpowerlevel10k%b%K{0} %244F\uE0B1 %76Fmaster ⇡2 %k%0F\uE0B0"
|
||||
print -P " %8F╰─%f █"
|
||||
print -P ""
|
||||
print -P "(%B1%b) %B%3FLean%f%b."
|
||||
print -P "(%B1%b) Lean."
|
||||
print -P ""
|
||||
print -P "(%B2%b) %B%4FClassic%f%b."
|
||||
print -P "(%B2%b) Classic."
|
||||
print -P ""
|
||||
print -P "%248F(r) Restart from the beginning.%f"
|
||||
print -P ""
|
||||
|
@ -288,8 +288,9 @@ function _p9k_ask_overwrite() {
|
|||
}
|
||||
|
||||
function _p9k_generate_config() {
|
||||
local -a cfg && cfg=("${(@f)$(< $_p9k_root_dir/config/p10k-$_p9k_style.zsh)}") || return
|
||||
cfg=("${(@)cfg/# typeset -g POWERLEVEL9K_MODE=*/ typeset -g POWERLEVEL9K_MODE=$POWERLEVEL9K_MODE}")
|
||||
local base && base="$(< $_p9k_root_dir/config/p10k-$_p9k_style.zsh)" || return
|
||||
local lines=("${(@f)base}")
|
||||
lines=("${(@)lines/# typeset -g POWERLEVEL9K_MODE=*/ typeset -g POWERLEVEL9K_MODE=$POWERLEVEL9K_MODE}")
|
||||
if [[ $POWERLEVEL9K_MODE == (powerline|compatible) && $_p9k_style == lean ]]; then
|
||||
local exp="''"
|
||||
elif (( _p9k_caps_narrow_icons )); then
|
||||
|
@ -297,16 +298,26 @@ function _p9k_generate_config() {
|
|||
else
|
||||
local exp="'\${P9K_VISUAL_IDENTIFIER}'"
|
||||
fi
|
||||
cfg=("${(@)cfg/# typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION=*/ typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION=$exp}")
|
||||
lines=("${(@)lines/# typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION=*/ typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION=$exp}")
|
||||
if (( _p9k_lines == 1 )); then
|
||||
local -a tmp
|
||||
local line
|
||||
for line in "$cfg[@]"; do
|
||||
for line in "$lines[@]"; do
|
||||
[[ $line == (' newline'|*'===[ Line #'*) ]] || tmp+=$line
|
||||
done
|
||||
cfg=("$tmp[@]")
|
||||
lines=("$tmp[@]")
|
||||
fi
|
||||
print -lr -- "$cfg[@]" >$zd/.p10k.zsh
|
||||
local header=${(%):-"# Generated by Powerlevel10k configuration wizard on %D{%Y-%m-%d at %H:%M %Z}."}$'\n'
|
||||
header+="# Based on romkatv/powerlevel10k/config/p10k-$_p9k_style.zsh"
|
||||
if [[ $commands[sum] == ('/bin'|'/usr/bin'|'/usr/local/bin')'/sum' ]]; then
|
||||
local -a sum
|
||||
if sum=($(sum <<<${base//$'\r\n'/$'\n'} 2>/dev/null)) && (( $#sum == 2 )); then
|
||||
header+=", checksum $sum[1]"
|
||||
fi
|
||||
fi
|
||||
header+=$'.\n'
|
||||
header+="# Wizard options: font=$POWERLEVEL9K_MODE, lines=$_p9k_lines, narrow-icons=$_p9k_caps_narrow_icons."$'\n#'
|
||||
print -lr -- "$header" "$lines[@]" >$zd/.p10k.zsh
|
||||
}
|
||||
|
||||
function _p9k_configure() {
|
||||
|
|
Loading…
Reference in a new issue