6e85ff5b44e81f5b9d743b6ba1df7ed7b62dc2df

Author
Isaac Wolkerstorfer <i@agnoster.net>
Committer
Isaac Wolkerstorfer <i@agnoster.net>
Date

Message

Updated documentation for agnoster theme

Diff

This diff is truncated to protect this page.

  1diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
  2index 9cfcff3d0e07fce6a23c7344e11e96b706d88eab..71bc25fc2df3c47c66eea0c1bf265734338c2aeb 100644
  3--- a/themes/agnoster.zsh-theme
  4+++ b/themes/agnoster.zsh-theme
  5@@ -1,22 +1,51 @@
  6+# vim:ft=zsh ts=2 sw=2 sts=2
  7+#
  8+# agnoster's Theme
  9+# A Powerline-inspired theme for ZSH
 10+#
 11+# # README
 12+#
 13+# In order for this theme to render correctly, you will need a
 14+# [Powerline-patched font](https://gist.github.com/1595572).
 15+#
 16+# In addition, I recommend the
 17+# [Solarized theme](https://github.com/altercation/solarized/) and, if you're
 18+# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
 19+# it has significantly better color fidelity.
 20+#
 21+# # Goals
 22+#
 23+# The aim of this theme is to only show you *relevant* information. Like most
 24+# prompts, it will only show git information when in a git working directory.
 25+# However, it goes a step further: everything from the current user and
 26+# hostname to whether the last call exited with an error to whether background
 27+# jobs are running in this shell will all be displayed automatically when
 28+# appropriate.
 29+
 30 ### Segment drawing
 31 # A few utility functions to make it easy and re-usable to draw segmented prompts
 32 
 33-CURRENT_BG=''
 34+CURRENT_BG='NONE'
 35 SEGMENT_SEPARATOR='⮀'
 36-function segment_start() {
 37-  local bg=$1
 38-  local fg=$2
 39-  if [[ -n $CURRENT_BG && $bg != $CURRENT_BG ]]; then
 40-    echo -n " %{%K{$bg}%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
 41+
 42+# Begin a segment
 43+# Takes two arguments, background and foreground. Both can be omitted,
 44+# rendering default background/foreground.
 45+prompt_segment() {
 46+  local bg fg
 47+  [[ -n $1 ]] && bg="%K{$1}" || bg="%k"
 48+  [[ -n $2 ]] && fg="%F{$2}" || fg="%f"
 49+  if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
 50+    echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
 51   else
 52-    echo -n "%{%K{$bg}%}"
 53+    echo -n "%{$bg%}%{$fg%} "
 54   fi
 55-  [[ -n $fg ]] && fg="%F{$fg}" || fg="%f"
 56-  echo -n "%{$fg%} "
 57-  CURRENT_BG=$bg
 58+  CURRENT_BG=$1
 59+  [[ -n $3 ]] && echo -n $3
 60 }
 61 
 62-function segment_stop() {
 63+# End the prompt, closing any open segments
 64+prompt_end() {
 65   if [[ -n $CURRENT_BG ]]; then
 66     echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
 67   else
 68@@ -29,58 +58,58 @@ function segment_stop() {
 69 ### Prompt components
 70 # Each component will draw itself, and hide itself if no information needs to be shown
 71 
 72-function prompt_context() {
 73+# Context: user@hostname (who am I and where am I)
 74+prompt_context() {
 75   local user=`whoami`
 76 
 77-  if [[ ("$user" != "$DEFAULT_USER") || (-n "$SSH_CLIENT") ]]; then
 78-    segment_start black
 79-    #echo -n "%{%F{yellow}%}$user%{%F{gray}%}@%{%F{green}%}%m%{%f%}"
 80-    echo -n "%(!.%{%F{yellow}%}.)$user@%m"
 81+  if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
 82+    prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m"
 83   fi
 84 }
 85 
 86-function prompt_git() {
 87+# Git: branch/detached head, dirty status
 88+prompt_git() {
 89+  local ref dirty
 90   if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
 91     ZSH_THEME_GIT_PROMPT_DIRTY='±'
 92-    local dirty=$(parse_git_dirty)
 93-    local ref
 94+    dirty=$(parse_git_dirty)
 95     ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
 96     if [[ -n $dirty ]]; then
 97-      segment_start yellow black
 98+      prompt_segment yellow black
 99     else
100-      segment_start green black
101+      prompt_segment green black
102     fi
103     echo -n "${ref/refs\/heads\//⭠ }$dirty"
104   fi