51677da85f98fb8003ea915edbef138df2f577b7

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #4091 from apjanke/agnoster-clarify-powerline

agnoster: Use current Powerline chars everywhere, and clarify behavior

Diff

 1diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
 2index ee0c2afb899093a32cb499cccda18ae51ebdcce9..e54346acf846a197cb35dfd2230a841b9cf73a9d 100644
 3--- a/themes/agnoster.zsh-theme
 4+++ b/themes/agnoster.zsh-theme
 5@@ -7,6 +7,9 @@
 6 #
 7 # In order for this theme to render correctly, you will need a
 8 # [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
 9+# Make sure you have a recent version: the code points that Powerline
10+# uses changed in 2012, and older versions will display incorrectly,
11+# in confusing ways.
12 #
13 # In addition, I recommend the
14 # [Solarized theme](https://github.com/altercation/solarized/) and, if you're
15@@ -27,12 +30,21 @@
16 
17 CURRENT_BG='NONE'
18 
19-# Fix odd char on mac
20-if [[ `uname` == 'Darwin' ]]; then
21-    SEGMENT_SEPARATOR='\ue0b0'
22-else
23-    SEGMENT_SEPARATOR=''
24-fi
25+# Special Powerline characters
26+
27+() {
28+  local LC_ALL="" LC_CTYPE="en_US.UTF-8"
29+  # NOTE: This segment separator character is correct.  In 2012, Powerline changed
30+  # the code points they use for their special characters. This is the new code point.
31+  # If this is not working for you, you probably have an old version of the 
32+  # Powerline-patched fonts installed. Download and install the new version.
33+  # Do not submit PRs to change this unless you have reviewed the Powerline code point
34+  # history and have new information.
35+  # This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of
36+  # what font the user is viewing this source code in. Do not replace the
37+  # escape sequence with a single literal character.
38+  SEGMENT_SEPARATOR=$'\ue0b0' # 
39+}
40 
41 # Begin a segment
42 # Takes two arguments, background and foreground. Both can be omitted,
43@@ -73,6 +85,12 @@ prompt_context() {
44 
45 # Git: branch/detached head, dirty status
46 prompt_git() {
47+
48+  local PL_BRANCH_CHAR
49+  () {
50+    local LC_ALL="" LC_CTYPE="en_US.UTF-8"
51+    PL_BRANCH_CHAR=$'\ue0a0'         # 
52+  }
53   local ref dirty mode repo_path
54   repo_path=$(git rev-parse --git-dir 2>/dev/null)
55 
56@@ -104,7 +122,7 @@ prompt_git() {
57     zstyle ':vcs_info:*' formats ' %u%c'
58     zstyle ':vcs_info:*' actionformats ' %u%c'
59     vcs_info
60-    echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}"
61+    echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
62   fi
63 }
64