From 59e96984a1cde0c50a1c37e4b8ed9fe7b028b3c4 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 5 Aug 2019 20:23:30 +0200 Subject: be more tolerant towards misconfigured locales; users with non-utf-8 locales will still have broken shells but at least p10k will work --- config/p10k-classic.zsh | 34 +++++++++++++++------------------- config/p10k-lean.zsh | 33 ++++++++++++++------------------- 2 files changed, 29 insertions(+), 38 deletions(-) (limited to 'config') diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index cbb4de47..4946a28a 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -1,19 +1,12 @@ -# Config for Powerlevel10k with classic powerline prompt style. Requires a powerline font. -# The color scheme is suitable for dark terminal background. -# -# Once you've installed Powerlevel10k, run these commands to apply classic style. -# -# curl -fsSL -o ~/p10k-classic.zsh https://raw.githubusercontent.com/romkatv/powerlevel10k/master/config/p10k-classic.zsh -# echo 'source ~/p10k-classic.zsh' >>! ~/.zshrc -# -# To customize your prompt, open ~/p10k-classic.zsh in your favorite text editor, change it and -# restart ZSH. The file is well-documented. +# Config for Powerlevel10k with classic powerline prompt style. Type `p10k configure` to generate +# your own config based on it. # # Tip: Looking for a nice color? Here's a one-liner to print colormap. # # for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done if [[ -o 'aliases' ]]; then + # Temporarily disable aliases. 'builtin' 'unsetopt' 'aliases' local p9k_classic_restore_aliases=1 else @@ -23,6 +16,7 @@ fi () { emulate -L zsh setopt no_unset + local LC_ALL=C.UTF-8 # Unset all configuration options. This allows you to apply configiguration changes without # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. @@ -277,6 +271,13 @@ fi # typeset -g POWERLEVEL9K_DIR_CLASSES=() #####################################[ vcs: git status ]###################################### + # Branch icon. Set this parameter to '\uF126' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + # Git status: feature:master#tag ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the lines below to customize how Git status looks. @@ -285,7 +286,7 @@ fi # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. local vcs='' # 'feature' or '@72f5c8a' if not on a branch. - vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' + vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}'${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}' # ':master' if the tracking branch name differs from local branch. vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' @@ -309,17 +310,10 @@ fi # ?42 if have untracked files. It's really a question mark, your font isn't broken. # See POWERLEVEL9K_VCS_UNTRACKED_ICON below if you want to use a different icon. # Remove the next line if you don't want to see untracked files at all. - vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}}' + vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F'${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}'${VCS_STATUS_NUM_UNTRACKED}}' # If P9K_CONTENT is not empty, leave it unchanged. It's either "loading" or from vcs_info. vcs="\${P9K_CONTENT:-$vcs}" - # Branch icon. Set this parameter to $'\uF126' for the popular Powerline branch icon. - typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= - - # Untracked files icon. It's really a question mark, your font isn't broken. - # Change the value of this parameter to show a different icon. - typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' - # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true # Install our own Git status formatter. @@ -330,6 +324,8 @@ fi # Enable counters for staged, unstaged, etc. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + # Icon color. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 # Custom icon. # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' # Custom prefix. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 52dcdcf4..8b994bbd 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -1,13 +1,5 @@ -# Config for Powerlevel10k with lean prompt style. Doesn't require a custom font but can take -# advantage of it if available. The color scheme is suitable for dark terminal background. -# -# Once you've installed Powerlevel10k, run these commands to apply lean style. -# -# curl -fsSL -o ~/p10k-lean.zsh https://raw.githubusercontent.com/romkatv/powerlevel10k/master/config/p10k-lean.zsh -# echo 'source ~/p10k-lean.zsh' >>! ~/.zshrc -# -# To customize your prompt, open ~/p10k-lean.zsh in your favorite text editor, change it and -# restart ZSH. The file is well-documented. +# Config for Powerlevel10k with classic powerline prompt style. Type `p10k configure` to generate +# your own config based on it. # # Tip: Looking for a nice color? Here's a one-liner to print colormap. # @@ -24,6 +16,7 @@ fi () { emulate -L zsh setopt no_unset + local LC_ALL=C.UTF-8 # Unset all configuration options. This allows you to apply configiguration changes without # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. @@ -262,6 +255,13 @@ fi # typeset -g POWERLEVEL9K_DIR_CLASSES=() #####################################[ vcs: git status ]###################################### + # Branch icon. Set this parameter to '\uF126' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + # Git status: feature:master#tag ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the lines below to customize how Git status looks. @@ -270,7 +270,7 @@ fi # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. local vcs='' # 'feature' or '@72f5c8a' if not on a branch. - vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' + vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}'${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}' # ':master' if the tracking branch name differs from local branch. vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' @@ -294,17 +294,10 @@ fi # ?42 if have untracked files. It's really a question mark, your font isn't broken. # See POWERLEVEL9K_VCS_UNTRACKED_ICON below if you want to use a different icon. # Remove the next line if you don't want to see untracked files at all. - vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}}' + vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F'${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}'${VCS_STATUS_NUM_UNTRACKED}}' # If P9K_CONTENT is not empty, leave it unchanged. It's either "loading" or from vcs_info. vcs="\${P9K_CONTENT:-$vcs}" - # Branch icon. Set this parameter to $'\uF126' for the popular Powerline branch icon. - typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= - - # Untracked files icon. It's really a question mark, your font isn't broken. - # Change the value of this parameter to show a different icon. - typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' - # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true # Install our own Git status formatter. @@ -315,6 +308,8 @@ fi # Enable counters for staged, unstaged, etc. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + # Icon color. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 # Custom icon. # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' # Custom prefix. -- cgit v1.2.3