sunrise.zsh-theme 3.05 KB
Newer Older
Adam Lindberg's avatar
Adam Lindberg committed
1
#-------------------------------------------------------------------------------
Adam Lindberg's avatar
Adam Lindberg committed
2
# Sunrise theme for oh-my-zsh by Adam Lindberg (eproxus@gmail.com)
3
# Intended to be used with Solarized: http://ethanschoonover.com/solarized
Adam Lindberg's avatar
Adam Lindberg committed
4
5
6
7
# (Needs Git plugin for current_branch method)
#-------------------------------------------------------------------------------

# Color shortcuts
8
9
10
11
12
R=$fg_no_bold[red]
G=$fg_no_bold[green]
M=$fg_no_bold[magenta]
Y=$fg_no_bold[yellow]
B=$fg_no_bold[blue]
Adam Lindberg's avatar
Adam Lindberg committed
13
14
15
RESET=$reset_color

if [ "$(whoami)" = "root" ]; then
16
    PROMPTCOLOR="%{$R%}" PREFIX="-!-";
Adam Lindberg's avatar
Adam Lindberg committed
17
else
18
    PROMPTCOLOR="" PREFIX="---";
Adam Lindberg's avatar
Adam Lindberg committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
fi

local return_code="%(?..%{$R%}%? ↵%{$RESET%})"

# Get the status of the working tree (copied and modified from git.zsh)
custom_git_prompt_status() {
  INDEX=$(git status --porcelain 2> /dev/null)
  STATUS=""
  # Non-staged
  if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
    STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
  fi
  if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
    STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
  fi
  if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
    STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
  fi
37
  if $(echo "$INDEX" | grep '^.M ' &> /dev/null); then
Adam Lindberg's avatar
Adam Lindberg committed
38
39
40
41
42
43
44
45
46
47
    STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
  elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
    STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
  elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
    STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
  fi
  # Staged
  if $(echo "$INDEX" | grep '^D  ' &> /dev/null); then
    STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_DELETED$STATUS"
  fi
48
  if $(echo "$INDEX" | grep '^R' &> /dev/null); then
Adam Lindberg's avatar
Adam Lindberg committed
49
50
    STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_RENAMED$STATUS"
  fi
51
  if $(echo "$INDEX" | grep '^M' &> /dev/null); then
Adam Lindberg's avatar
Adam Lindberg committed
52
53
54
55
56
    STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED$STATUS"
  fi
  if $(echo "$INDEX" | grep '^A' &> /dev/null); then
    STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_ADDED$STATUS"
  fi
57

58
  if $(echo -n "$STATUS" | grep '.*' &> /dev/null); then
59
60
61
    STATUS="$ZSH_THEME_GIT_STATUS_PREFIX$STATUS"
  fi

Adam Lindberg's avatar
Adam Lindberg committed
62
63
64
65
66
67
  echo $STATUS
}

# get the name of the branch we are on (copied and modified from git.zsh)
function custom_git_prompt() {
  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
68
  echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(git_prompt_ahead)$(custom_git_prompt_status)$ZSH_THEME_GIT_PROMPT_SUFFIX"
Adam Lindberg's avatar
Adam Lindberg committed
69
70
}

71
72
# %B sets bold text
PROMPT='%B$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} '
Adam Lindberg's avatar
Adam Lindberg committed
73
74
RPS1="${return_code}"

75
76
ZSH_THEME_GIT_PROMPT_PREFIX="%{$Y%}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$Y%}›%{$RESET%} "
Adam Lindberg's avatar
Adam Lindberg committed
77

78
79
80
ZSH_THEME_GIT_PROMPT_DIRTY="%{$R%}*"
ZSH_THEME_GIT_PROMPT_CLEAN=""

81
82
ZSH_THEME_GIT_PROMPT_AHEAD="%{$B%}➔"

83
84

ZSH_THEME_GIT_STATUS_PREFIX=" "
Adam Lindberg's avatar
Adam Lindberg committed
85
86
87
88
89
90
91
92

# Staged
ZSH_THEME_GIT_PROMPT_STAGED_ADDED="%{$G%}A"
ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED="%{$G%}M"
ZSH_THEME_GIT_PROMPT_STAGED_RENAMED="%{$G%}R"
ZSH_THEME_GIT_PROMPT_STAGED_DELETED="%{$G%}D"

# Not-staged
93
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}?"
Adam Lindberg's avatar
Adam Lindberg committed
94
95
96
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$R%}M"
ZSH_THEME_GIT_PROMPT_DELETED="%{$R%}D"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$R%}UU"