aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md47
-rwxr-xr-xinternal/p10k.zsh14
-rwxr-xr-xinternal/wizard.zsh152
3 files changed, 120 insertions, 93 deletions
diff --git a/README.md b/README.md
index ecb995c0..010ef7ab 100644
--- a/README.md
+++ b/README.md
@@ -83,16 +83,8 @@ Add `antibody bundle romkatv/powerlevel10k` to your `~/.zshrc`.
### For new users
-If you are new to Powerlevel10k/9k and don't have your own config yet, start with the
-[lean](https://github.com/romkatv/powerlevel10k/blob/master/config/p10k-lean.zsh) style.
-
-```zsh
-curl -fsSL -o ~/p10k-lean.zsh https://raw.githubusercontent.com/romkatv/powerlevel10k/master/config/p10k-lean.zsh
-echo 'source ~/p10k-lean.zsh' >>! ~/.zshrc
-```
-
-That's it! Your have a fast and functional prompt. If you want to customize it, edit
-`~/p10k-lean.zsh` and restart ZSH.
+On the first run Powerlevel10k configuration wizard will ask you a few questions and configure
+your prompt. If it doesn't trigger automatically, type `p9k_configure`.
### For existing users
@@ -101,18 +93,35 @@ will pick them up and provide you with the same prompt UI you are used to. Power
all configuration options used by Powerlevel9k. See Powerlevel9k
[configuration guide](https://github.com/bhilburn/powerlevel9k#prompt-customization).
-If you aren't completely satisfied with your prompt or looking for something fresh, try
-[lean](https://github.com/romkatv/powerlevel10k/blob/master/config/p10k-lean.zsh) config.
+To go beyond the functionality of Powerlevel9k, type `p9k_configure` and explore unique styles and
+features Powerlevel10k has to offer.
## Fonts
-Depending on your configuration, you might need to install a Powerline font. Follow the
-[font installation guide](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions#step-2-install-a-powerline-font)
-from Powerlevel9k.
+Powerlevel10k doesn't require custom fonts but it can take advantage of them if they are available.
+Some of the style options in Powerlevel10k are available only when using
+[Nerd Fonts](https://github.com/ryanoasis/nerd-fonts).
+
+If you don't know which font to use, download
+[these 4 fonts](https://github.com/romkatv/dotfiles-public/tree/master/.local/share/fonts/NerdFonts)
+and install them. In most systems you can install fonts simply by clicking on the `ttf` files. Then
+change your terminal's font to `MesloLGS NF` (NF stands for Nerd Fonts).
+
+- **iTerm2**: Open *Preferences → Profiles → Text → Change Font*. Set *Font* to `MesloLGS NF`.
+- **GNOME**: Type this command:
+
+```zsh
+sudo apt install libglib2.0-bin
+gsettings set org.gnome.desktop.interface monospace-font-name 'MesloLGS NF 11'
+```
+
+- **Windows Command Prompt** (the default terminal app): Use
+ [this script](https://gist.github.com/romkatv/aa7a70fe656d8b655e3c324eb10f6a8b).
+- **Visual Studio Code** (builtin terminal): *Open File → Preferences → Settings*, enter
+ `terminal.integrated.fontFamily` in the search box and set the value to `MesloLGS NF`.
-[Lean](https://github.com/romkatv/powerlevel10k/blob/master/config/p10k-lean.zsh) config doesn't
-require custom fonts. It'll work even with regular system fonts. If you are having trouble with
-Powerline fonts, try this config.
+(Using a different terminal and know how to set font for it? Share your knowledge by sending a PR
+expanding the list!)
## Try it in Docker
@@ -123,8 +132,6 @@ the theme. Once you exit zsh, the image is deleted.
docker run -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -e TERM -it --rm ubuntu bash -uexc '
cd && apt update && apt install -y zsh git
git clone https://github.com/romkatv/powerlevel10k.git
- cp ~/powerlevel10k/config/p10k-lean.zsh ~/
- echo "source ~/p10k-lean.zsh" >>~/.zshrc
echo "source ~/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc
cd ~/powerlevel10k
exec zsh'
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index ce6cfa14..87aaa184 100755
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -3277,7 +3277,18 @@ _p9k_precmd() {
unset _p9k_real_zle_rprompt_indent
fi
- _p9k_must_init && _p9k_init
+ if _p9k_must_init; then
+ if (( !__p9k_configured )); then
+ __p9k_configured=1
+ if [[ -z ${parameters[(i)POWERLEVEL9K_*]} ]] && _p9k_can_configure -q; then
+ if $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir; then
+ source $__p9k_cfg_path
+ _p9k_must_init
+ fi
+ fi
+ fi
+ _p9k_init
+ fi
unsetopt localoptions
prompt_opts=(cr percent sp subst)
@@ -4294,6 +4305,7 @@ _p9k_deinit() {
}
typeset -gi __p9k_enabled=0
+typeset -gi __p9k_configured=0
prompt_powerlevel9k_setup() {
emulate -L zsh && setopt no_hist_expand extended_glob
diff --git a/internal/wizard.zsh b/internal/wizard.zsh
index abd88591..8fa3448b 100755
--- a/internal/wizard.zsh
+++ b/internal/wizard.zsh
@@ -139,10 +139,11 @@ function quit() {
print -P "Powerlevel10k configuration wizard has been aborted. To run it again, type:"
print -P ""
print -P " %2Fp9k_configure%f"
+ print -P ""
else
- print -P "Powerlevel10k configuration wizard will run again next time unless"
- print -P "you define at least one Powerlevel10k configuration option. To define"
- print -P "an option that does nothing except for disabling Powerlevel10k"
+ print -P "Powerlevel10k configuration wizard has been aborted. It will run again"
+ print -P "next time unless you define at least one Powerlevel10k configuration option."
+ print -P "To define an option that does nothing except for disabling Powerlevel10k"
print -P "configuration wizard, type the following command:"
print -P ""
print -P " %2Fecho%f %3F'POWERLEVEL9K_MODE='%f >>! $__p9k_zshrc_u"
@@ -150,7 +151,9 @@ function quit() {
print -P "To run Powerlevel10k configuration wizard right now, type:"
print -P ""
print -P " %2Fp9k_configure%f"
+ print -P ""
fi
+ exit 1
}
function ask_diamond() {
@@ -178,9 +181,9 @@ function ask_diamond() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [ynq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [ynq]: %b"} || quit
case $key in
- q) quit; return 1;;
+ q) quit;;
y) cap_diamond=1; break;;
n) cap_diamond=0; break;;
esac
@@ -206,10 +209,10 @@ function ask_lock() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [ynrq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
y) cap_lock=1; break;;
n) cap_lock=0; break;;
esac
@@ -234,10 +237,10 @@ function ask_python() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [ynrq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
y) cap_python=1; break;;
n) cap_python=0; break;;
esac
@@ -272,10 +275,10 @@ function ask_narrow_icons() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [ynrq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
y) cap_narrow_icons=1; options+='small icons'; break;;
n) cap_narrow_icons=0; break;;
esac
@@ -301,10 +304,10 @@ function ask_style() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [12rq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [12rq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
1) style=lean; options+=lean; break;;
2) style=classic; options+=classic; break;;
esac
@@ -335,10 +338,10 @@ function ask_color() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [123rq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [123rq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
1) color=1; options+=light; break;;
2) color=2; options+=medium; break;;
3) color=3; options+=dark; break;;
@@ -377,10 +380,10 @@ function ask_extra_icons() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [12rq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [12rq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
1) extra_icons=('' ''); options+='few icons'; break;;
2) extra_icons=("$many[@]"); options+='many icons'; break;;
esac
@@ -407,10 +410,10 @@ function ask_prefixes() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [12rq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [12rq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
1) prefixes=('' ''); break;;
2) prefixes=("$fluent[@]"); options+=fluent; break;;
esac
@@ -447,10 +450,10 @@ function ask_separators() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
1) left_sep=$right_angle; right_sep=$left_angle; options+='angled sep'; break;;
2) left_sep=$vertical_bar; right_sep=$vertical_bar; options+='vertical sep'; break;;
3)
@@ -495,10 +498,10 @@ function ask_heads() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [12rq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [12rq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
1) left_head=$right_triangle; right_head=$left_triangle; options+='sharp heads'; break;;
2) left_head=$fade_out; right_head=$fade_in; options+='blurred heads'; break;;
3)
@@ -550,10 +553,10 @@ function ask_tails() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
1) left_tail=''; right_tail=''; options+='flat tails'; break;;
2) left_tail=$fade_in; right_tail=$fade_out; options+='blurred tails'; break;;
3)
@@ -595,10 +598,10 @@ function ask_num_lines() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [12rq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [12rq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
1) num_lines=1; options+='1 line'; break;;
2) num_lines=2; options+='2 lines'; break;;
esac
@@ -631,10 +634,10 @@ function ask_gap_char() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [123rq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [123rq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
1) gap_char=" "; options+=disconnected; break;;
2) gap_char="·"; options+=dotted; break;;
3) gap_char="─"; options+=solid; break;;
@@ -672,10 +675,10 @@ function ask_frame() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [123rq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [123rq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
1) left_frame=0; right_frame=0; options+='no frame'; break;;
2) left_frame=1; right_frame=0; options+='left frame'; break;;
3) left_frame=0; right_frame=1; options+='right frame'; break;;
@@ -706,10 +709,10 @@ function ask_empty_line() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [12rq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [12rq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
1) empty_line=0; options+='compact'; break;;
2) empty_line=1; options+='sparse'; break;;
esac
@@ -733,10 +736,10 @@ function ask_confirm() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [yrq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [yrq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
y) break;;
esac
done
@@ -761,10 +764,10 @@ function ask_config_overwrite() {
print -P ""
local key=
- read -k key${(%):-"?%BChoice [yrq]: %b"} || return 1
+ read -k key${(%):-"?%BChoice [yrq]: %b"} || quit
case $key in
- q) quit; return 1;;
- r) return 2;;
+ q) quit;;
+ r) return 1;;
y)
config_backup="$(mktemp ${TMPDIR:-/tmp}/$__p9k_cfg_basename.XXXXXXXXXX)" || return 1
cp $__p9k_cfg_path $config_backup
@@ -925,7 +928,12 @@ function write_zshrc() {
print -lP -- ' '${^comments} " %2Fsource%f %B$__p9k_cfg_path_u%b"
}
-_p9k_can_configure || return
+if (( force )); then
+ _p9k_can_configure || return
+else
+ _p9k_can_configure -q || return
+fi
+
source $__p9k_root_dir/internal/icons.zsh || return
while true; do
@@ -937,13 +945,13 @@ while true; do
local -a prefixes=('' '')
local -a options=()
- ask_diamond || { (( $? == 2 )) && continue || return }
+ ask_diamond || continue
if [[ -n $AWESOME_GLYPHS_LOADED ]]; then
POWERLEVEL9K_MODE=awesome-mapped-fontconfig
else
- ask_lock '\uF023' || { (( $? == 2 )) && continue || return }
+ ask_lock '\uF023' || continue
if (( ! cap_lock )); then
- ask_lock '\uE138' "Let's try another one." || { (( $? == 2 )) && continue || return }
+ ask_lock '\uE138' "Let's try another one." || continue
if (( cap_lock )); then
(( cap_diamond )) && POWERLEVEL9K_MODE=awesome-patched || POWERLEVEL9K_MODE=flat
else
@@ -952,7 +960,7 @@ while true; do
elif (( ! cap_diamond )); then
POWERLEVEL9K_MODE=awesome-fontconfig
else
- ask_python || { (( $? == 2 )) && continue || return }
+ ask_python || continue
(( cap_python )) && POWERLEVEL9K_MODE=awesome-fontconfig || POWERLEVEL9K_MODE=nerdfont-complete
fi
fi
@@ -975,20 +983,20 @@ while true; do
right_head=$fade_in
fi
_p9k_init_icons
- ask_narrow_icons || { (( $? == 2 )) && continue || return }
- ask_style || { (( $? == 2 )) && continue || return }
- ask_color || { (( $? == 2 )) && continue || return }
- ask_separators || { (( $? == 2 )) && continue || return }
- ask_heads || { (( $? == 2 )) && continue || return }
- ask_tails || { (( $? == 2 )) && continue || return }
- ask_num_lines || { (( $? == 2 )) && continue || return }
- ask_gap_char || { (( $? == 2 )) && continue || return }
- ask_frame || { (( $? == 2 )) && continue || return }
- ask_empty_line || { (( $? == 2 )) && continue || return }
- ask_extra_icons || { (( $? == 2 )) && continue || return }
- ask_prefixes || { (( $? == 2 )) && continue || return }
- ask_confirm || { (( $? == 2 )) && continue || return }
- ask_config_overwrite || { (( $? == 2 )) && continue || return }
+ ask_narrow_icons || continue
+ ask_style || continue
+ ask_color || continue
+ ask_separators || continue
+ ask_heads || continue
+ ask_tails || continue
+ ask_num_lines || continue
+ ask_gap_char || continue
+ ask_frame || continue
+ ask_empty_line || continue
+ ask_extra_icons || continue
+ ask_prefixes || continue
+ ask_confirm || continue
+ ask_config_overwrite || continue
break
done