From 4cd281ba1be0d8a2e44f96bdb1f2a98b15f54c47 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Thu, 25 Jun 2015 20:13:59 -0400 Subject: agnoster: Define Powerline chars with escape sequence, and use same character on all platforms. Add clarifying comments. This makes everything consistent with the current Powerline-patched fonts definitions. --- themes/agnoster.zsh-theme | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'themes/agnoster.zsh-theme') diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 3a0c58b89..3e454a0a0 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -7,6 +7,9 @@ # # In order for this theme to render correctly, you will need a # [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts). +# Make sure you have a recent version: the code points that Powerline +# uses changed in 2012, and older versions will display incorrectly, +# in confusing ways. # # In addition, I recommend the # [Solarized theme](https://github.com/altercation/solarized/) and, if you're @@ -27,12 +30,19 @@ CURRENT_BG='NONE' -# Fix odd char on mac -if [[ `uname` == 'Darwin' ]]; then - SEGMENT_SEPARATOR='\ue0b0' -else - SEGMENT_SEPARATOR='' -fi +# Special Powerline characters + +# NOTE: This segment separator character is correct. In 2012, Powerline changed +# the code points they use for their special characters. This is the new code point. +# If this is not working for you, you probably have an old version of the +# Powerline-patched fonts installed. Download and install the new version. +# Do not submit PRs to change this unless you have reviewed the Powerline code point +# history and have new information. +# This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of +# what font the user is viewing this source code in. Do not replace the +# escape sequence with a single literal character. +SEGMENT_SEPARATOR='\ue0b0' #  + # Begin a segment # Takes two arguments, background and foreground. Both can be omitted, @@ -73,6 +83,7 @@ prompt_context() { # Git: branch/detached head, dirty status prompt_git() { + local PL_BRANCH_CHAR='\ue0a0' #  local ref dirty mode repo_path repo_path=$(git rev-parse --git-dir 2>/dev/null) @@ -104,7 +115,7 @@ prompt_git() { zstyle ':vcs_info:*' formats ' %u%c' zstyle ':vcs_info:*' actionformats ' %u%c' vcs_info - echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}" + echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" fi } -- cgit v1.2.3-70-g09d2 From c82deedc97f7578fa0a8a2dd3c8b598a166bfd04 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 3 Jul 2015 01:44:47 -0400 Subject: agnoster: Protect Unicode esape sequences with local LC_* settings --- themes/agnoster.zsh-theme | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'themes/agnoster.zsh-theme') diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 3e454a0a0..6444dfa68 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -32,17 +32,19 @@ CURRENT_BG='NONE' # Special Powerline characters -# NOTE: This segment separator character is correct. In 2012, Powerline changed -# the code points they use for their special characters. This is the new code point. -# If this is not working for you, you probably have an old version of the -# Powerline-patched fonts installed. Download and install the new version. -# Do not submit PRs to change this unless you have reviewed the Powerline code point -# history and have new information. -# This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of -# what font the user is viewing this source code in. Do not replace the -# escape sequence with a single literal character. -SEGMENT_SEPARATOR='\ue0b0' #  - +() { + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + # NOTE: This segment separator character is correct. In 2012, Powerline changed + # the code points they use for their special characters. This is the new code point. + # If this is not working for you, you probably have an old version of the + # Powerline-patched fonts installed. Download and install the new version. + # Do not submit PRs to change this unless you have reviewed the Powerline code point + # history and have new information. + # This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of + # what font the user is viewing this source code in. Do not replace the + # escape sequence with a single literal character. + SEGMENT_SEPARATOR=$'\ue0b0' #  +} # Begin a segment # Takes two arguments, background and foreground. Both can be omitted, @@ -83,7 +85,12 @@ prompt_context() { # Git: branch/detached head, dirty status prompt_git() { - local PL_BRANCH_CHAR='\ue0a0' #  + + local PL_BRANCH_CHAR + () { + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + PL_BRANCH_CHAR=$'\ue0a0' #  + } local ref dirty mode repo_path repo_path=$(git rev-parse --git-dir 2>/dev/null) -- cgit v1.2.3-70-g09d2 From b875df8970a67d02eef74f1aad0b60f42fedb356 Mon Sep 17 00:00:00 2001 From: Brian Degenhardt Date: Mon, 27 Jul 2015 14:19:23 -0700 Subject: agnoster: speed up git prompt Problem On detached-refs, the git prompt is very slow because it uses a command to output all refs, which takes 32s on the twitter internal git repo. Solution Use git-rev-parse instead of git-show-ref to only output the head ref. Runtime drops to 0.03 seconds. Note Interestingly, git-rev-parse isn't slow without the --head arguement so I'll probably be cooking up a patch for the git team to speed this up eventually, but it's still pointless to sigpipe git as it walks the filesystem. --- themes/agnoster.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'themes/agnoster.zsh-theme') diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 3a0c58b89..ee0c2afb8 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -78,7 +78,7 @@ prompt_git() { if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then dirty=$(parse_git_dirty) - ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" if [[ -n $dirty ]]; then prompt_segment yellow black else -- cgit v1.2.3-70-g09d2