diff options
Diffstat (limited to 'internal/wizard.zsh')
-rwxr-xr-x | internal/wizard.zsh | 110 |
1 files changed, 58 insertions, 52 deletions
diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 09977a68..2c1d9d41 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -19,7 +19,7 @@ fi local -ri force local -r font_base_url='https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts' -local -ri wizard_columns=$((COLUMNS < 80 ? COLUMNS : 80)) +local -ri wizard_columns=$((COLUMNS < 83 ? COLUMNS : 83)) local -ri prompt_indent=2 @@ -46,33 +46,36 @@ local -r slanted_bar='\uE0BD' local -r cursor='%1{\e[07m \e[27m%}' +local -r time_24h='16:23:42' +local -r time_12h='04:23:42 PM' + local -ra lean_left=( - '%$frame_color[$color]F╭─ ' '${extra_icons[1]:+$extra_icons[1] }%31F$extra_icons[2]%B%39F~%b%31F/%B%39Fsrc%b%f $prefixes[1]%76F$extra_icons[3]master%f ' + '%$frame_color[$color]F╭─ ' '${extra_icons[1]:+%B%f$extra_icons[1] %b}%31F$extra_icons[2]%B%39F~%b%31F/%B%39Fsrc%b%f $prefixes[1]%76F$extra_icons[3]master%f ' '%$frame_color[$color]F╰─' '%76F$prompt_char%f ${buffer:-$cursor}' ) local -ra lean_right=( - ' $prefixes[2]%101F$extra_icons[4]5s%f${show_time:+ $prefixes[3]%66F$extra_icons[5]16:23:42%f}' ' %$frame_color[$color]F─╮%f' + ' $prefixes[2]%101F$extra_icons[4]5s%f${time:+ $prefixes[3]%66F$extra_icons[5]$time%f}' ' %$frame_color[$color]F─╮%f' '' ' %$frame_color[$color]F─╯%f' ) local -ra lean_8colors_left=( - '%$frame_color[$color]F╭─ ' '${extra_icons[1]:+$extra_icons[1] }%4F$extra_icons[2]%4F~/src%f $prefixes[1]%2F$extra_icons[3]master%f ' + '%$frame_color[$color]F╭─ ' '${extra_icons[1]:+%f$extra_icons[1] }%4F$extra_icons[2]%4F~/src%f $prefixes[1]%2F$extra_icons[3]master%f ' '%$frame_color[$color]F╰─' '%2F$prompt_char%f ${buffer:-$cursor}' ) local -ra lean_8colors_right=( - ' $prefixes[2]%3F$extra_icons[4]5s%f${show_time:+ $prefixes[3]%6F$extra_icons[5]16:23:42%f}' ' %$frame_color[$color]F─╮%f' + ' $prefixes[2]%3F$extra_icons[4]5s%f${time:+ $prefixes[3]%6F$extra_icons[5]$time%f}' ' %$frame_color[$color]F─╮%f' '' ' %$frame_color[$color]F─╯%f' ) local -ra classic_left=( - '%$frame_color[$color]F╭─' '%F{$bg_color[$color]}$left_tail%K{$bg_color[$color]} ${extra_icons[1]:+$extra_icons[1]%K{$bg_color[$color]\} %$sep_color[$color]F$left_subsep%f }%31F$extra_icons[2]%B%39F~%b%K{$bg_color[$color]}%31F/%B%39Fsrc%b%K{$bg_color[$color]} %$sep_color[$color]F$left_subsep%f %$prefix_color[$color]F$prefixes[1]%76F$extra_icons[3]master %k%$bg_color[$color]F$left_head%f' + '%$frame_color[$color]F╭─' '%F{$bg_color[$color]}$left_tail%K{$bg_color[$color]} ${extra_icons[1]:+%255F$extra_icons[1] %$sep_color[$color]F$left_subsep%f }%31F$extra_icons[2]%B%39F~%b%K{$bg_color[$color]}%31F/%B%39Fsrc%b%K{$bg_color[$color]} %$sep_color[$color]F$left_subsep%f %$prefix_color[$color]F$prefixes[1]%76F$extra_icons[3]master %k%$bg_color[$color]F$left_head%f' '%$frame_color[$color]F╰─' '%f ${buffer:-$cursor}' ) local -ra classic_right=( - '%$bg_color[$color]F$right_head%K{$bg_color[$color]}%f %$prefix_color[$color]F$prefixes[2]%101F5s $extra_icons[4]${show_time:+%$sep_color[$color]F$right_subsep %$prefix_color[$color]F$prefixes[3]%66F16:23:42 $extra_icons[5]}%k%F{$bg_color[$color]}$right_tail%f' '%$frame_color[$color]F─╮%f' + '%$bg_color[$color]F$right_head%K{$bg_color[$color]}%f %$prefix_color[$color]F$prefixes[2]%101F5s $extra_icons[4]${time:+%$sep_color[$color]F$right_subsep %$prefix_color[$color]F$prefixes[3]%66F$time $extra_icons[5]}%k%F{$bg_color[$color]}$right_tail%f' '%$frame_color[$color]F─╮%f' '' '%$frame_color[$color]F─╯%f' ) @@ -82,17 +85,17 @@ local -ra pure_left=( ) local -ra pure_right=( - '${pure_use_rprompt+%F{$pure_color[yellow]\}5s%f${show_time:+ }}${show_time:+%F{$pure_color[grey]\}16:23:42%f}' '' + '${pure_use_rprompt+%F{$pure_color[yellow]\}5s%f${time:+ }}${time:+%F{$pure_color[grey]\}$time%f}' '' '' '' ) local -ra rainbow_left=( - '%$frame_color[$color]F╭─' '%F{${${extra_icons[1]:+7}:-4}}$left_tail${extra_icons[1]:+%K{7\} $extra_icons[1] %K{4\}%7F$left_sep}%K{4}%254F $extra_icons[2]%B%255F~%b%K{4}%254F/%B%255Fsrc%b%K{4} %K{2}%4F$left_sep %0F$prefixes[1]$extra_icons[3]master %k%2F$left_head%f' + '%$frame_color[$color]F╭─' '%F{${${extra_icons[1]:+7}:-4}}$left_tail${extra_icons[1]:+%K{7\}%232F $extra_icons[1] %K{4\}%7F$left_sep}%K{4}%254F $extra_icons[2]%B%255F~%b%K{4}%254F/%B%255Fsrc%b%K{4} %K{2}%4F$left_sep %0F$prefixes[1]$extra_icons[3]master %k%2F$left_head%f' '%$frame_color[$color]F╰─' '%f ${buffer:-$cursor}' ) local -ra rainbow_right=( - '%3F$right_head%K{3} %0F$prefixes[2]5s $extra_icons[4]%3F${show_time:+%7F$right_sep%K{7\} %0F$prefixes[3]16:23:42 $extra_icons[5]%7F}%k$right_tail%f' '%$frame_color[$color]F─╮%f' + '%3F$right_head%K{3} %0F$prefixes[2]5s $extra_icons[4]%3F${time:+%7F$right_sep%K{7\} %0F$prefixes[3]$time $extra_icons[5]%7F}%k$right_tail%f' '%$frame_color[$color]F─╮%f' '' '%$frame_color[$color]F─╯%f' ) @@ -609,21 +612,20 @@ function ask_debian() { done } -function ask_narrow_icons() { +function ask_icon_padding() { if [[ $POWERLEVEL9K_MODE == (powerline|compatible|ascii) ]]; then - cap_narrow_icons=0 + POWERLEVEL9K_ICON_PADDING=none return 0 fi local text="X" text+="%1F${icons[VCS_GIT_ICON]// }%fX" text+="%2F${icons[VCS_GIT_GITHUB_ICON]// }%fX" - text+="%3F${icons[DATE_ICON]// }%fX" - text+="%4F${icons[TIME_ICON]// }%fX" - text+="%5F${icons[RUBY_ICON]// }%fX" - text+="%6F${icons[HOME_ICON]// }%fX" - text+="%1F${icons[HOME_SUB_ICON]// }%fX" - text+="%2F${icons[FOLDER_ICON]// }%fX" - text+="%3F${icons[RAM_ICON]// }%fX" + text+="%3F${icons[TIME_ICON]// }%fX" + text+="%4F${icons[RUBY_ICON]// }%fX" + text+="%5F${icons[HOME_ICON]// }%fX" + text+="%6F${icons[HOME_SUB_ICON]// }%fX" + text+="%1F${icons[FOLDER_ICON]// }%fX" + text+="%2F${icons[RAM_ICON]// }%fX" while true; do clear flowing -c "%BDo all these icons %b%2Ffit between the crosses%f%B?%b" @@ -643,8 +645,8 @@ function ask_narrow_icons() { case $key in q) quit;; r) return 1;; - y) cap_narrow_icons=1; options+='small icons'; break;; - n) cap_narrow_icons=0; options+='large icons'; break;; + y) POWERLEVEL9K_ICON_PADDING=none; options+='small icons'; break;; + n) POWERLEVEL9K_ICON_PADDING=moderate; options+='large icons'; break;; esac done } @@ -751,10 +753,10 @@ function ask_charset() { left_frame=0 right_frame=0 POWERLEVEL9K_MODE=ascii + POWERLEVEL9K_ICON_PADDING=none cap_diamond=0 cap_python=0 cap_debian=0 - cap_narrow_icons=1 cap_lock=0 cap_arrow=0 break @@ -925,33 +927,48 @@ function ask_ornaments_color() { function ask_time() { if (( wizard_columns < 80 )) && [[ $style != pure ]]; then - show_time= + time= return 0 fi while true; do + local extra= clear flowing -c "%BShow current time?%b" print -P "" - print -P "%B(y) Yes.%b" + print -P "%B(1) No.%b" print -P "" - show_time=1 print_prompt + time= print_prompt print -P "" - print -P "%B(n) No.%b" + print -P "%B(2) 24-hour format.%b" print -P "" - show_time= print_prompt + time=$time_24h print_prompt print -P "" + if [[ $wizard_columns -ge 83 || $style == lean* || $POWERLEVEL9K_ICON_PADDING == none ]]; then + extra+=3 + print -P "%B(3) 12-hour format.%b" + print -P "" + time=$time_12h print_prompt + print -P "" + fi print -P "(r) Restart from the beginning." print -P "(q) Quit and do nothing." print -P "" local key= - read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit -c + read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; - y) show_time=1; options+=time; break;; - n) show_time=; break;; + 1) time=; break;; + 2) time=$time_24h; options+='24h time'; break;; + 3) + if [[ $extra == *3* ]]; then + time=$time_12h + options+='12h time' + break + fi + ;; esac done } @@ -1040,21 +1057,7 @@ function ask_extra_icons() { local branch_icon=${(g::)icons[VCS_BRANCH_ICON]} local duration_icon=${(g::)icons[EXECUTION_TIME_ICON]} local time_icon=${(g::)icons[TIME_ICON]} - if (( cap_narrow_icons )); then - os_icon=${os_icon// } - dir_icon=${dir_icon// } - vcs_icon=${vcs_icon// } - duration_icon=${duration_icon// } - time_icon=${time_icon// } - fi branch_icon=${branch_icon// } - if [[ $style == classic ]]; then - os_icon="%B%255F$os_icon%f%b" - elif [[ $style == rainbow ]]; then - os_icon="%B%F{232}$os_icon%f%b" - elif [[ $style != lean_8colors ]]; then - os_icon="%B%f$os_icon%b" - fi local few=('' '' '' '' '') local many=("$os_icon" "$dir_icon " "$vcs_icon $branch_icon " "$duration_icon " "$time_icon ") while true; do @@ -1776,9 +1779,7 @@ function generate_config() { else sub MODE $POWERLEVEL9K_MODE - if (( ! cap_narrow_icons )); then - sub ICON_PADDING moderate - fi + sub ICON_PADDING $POWERLEVEL9K_ICON_PADDING if [[ $POWERLEVEL9K_MODE == compatible ]]; then sub STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION "'х'" @@ -1945,8 +1946,11 @@ function generate_config() { done fi - if [[ -n $show_time ]]; then + if [[ -n $time ]]; then uncomment time + if [[ $time == $time_12h ]]; then + sub TIME_FORMAT "'%D{%I:%M:%S %p}'" + fi fi if (( num_lines == 1 )); then @@ -2057,10 +2061,11 @@ fi while true; do local instant_prompt=verbose zshrc_content= zshrc_backup= zshrc_backup_u= local -i zshrc_has_cfg=0 zshrc_has_instant_prompt=0 write_zshrc=0 - local POWERLEVEL9K_MODE= style= config_backup= config_backup_u= gap_char=' ' prompt_char='❯' - local left_subsep= right_subsep= left_tail= right_tail= left_head= right_head= show_time= + local POWERLEVEL9K_MODE= POWERLEVEL9K_ICON_PADDING=moderate style= config_backup= config_backup_u= + local gap_char=' ' prompt_char='❯' + local left_subsep= right_subsep= left_tail= right_tail= left_head= right_head= time= local -i num_lines=0 empty_line=0 color=2 left_frame=1 right_frame=1 transient_prompt=0 - local -i cap_diamond=0 cap_python=0 cap_debian=0 cap_narrow_icons=0 cap_lock=0 cap_arrow=0 + local -i cap_diamond=0 cap_python=0 cap_debian=0 cap_lock=0 cap_arrow=0 local -a extra_icons=('' '' '') local -a frame_color=(244 242 240 238) local -a color_name=(Lightest Light Dark Darkest) @@ -2144,8 +2149,9 @@ while true; do fi _p9k_init_icons + ask_icon_padding || continue + _p9k_init_icons - ask_narrow_icons || continue ask_style || continue ask_charset || continue ask_color_scheme || continue |