2014-03-08 18:51:16 +01:00
|
|
|
|
# Sunrise theme for oh-my-zsh
|
2011-06-07 15:40:18 +02:00
|
|
|
|
# Intended to be used with Solarized: http://ethanschoonover.com/solarized
|
2011-05-31 11:46:26 +02:00
|
|
|
|
# (Needs Git plugin for current_branch method)
|
|
|
|
|
|
|
|
|
|
# Color shortcuts
|
2012-01-16 16:39:28 +01:00
|
|
|
|
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]
|
2011-05-31 11:46:26 +02:00
|
|
|
|
RESET=$reset_color
|
|
|
|
|
|
2014-10-09 13:44:54 +02:00
|
|
|
|
if [ "$USER" = "root" ]; then
|
2015-11-02 08:12:38 +01:00
|
|
|
|
PROMPTCOLOR="%{$R%}" PROMPTPREFIX="-!-";
|
2011-05-31 11:46:26 +02:00
|
|
|
|
else
|
2015-11-02 08:12:38 +01:00
|
|
|
|
PROMPTCOLOR="" PROMPTPREFIX="---";
|
2011-05-31 11:46:26 +02:00
|
|
|
|
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
|
2011-06-07 15:40:32 +02:00
|
|
|
|
if $(echo "$INDEX" | grep '^.M ' &> /dev/null); then
|
2011-05-31 11:46:26 +02:00
|
|
|
|
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
|
2011-06-07 15:40:32 +02:00
|
|
|
|
if $(echo "$INDEX" | grep '^R' &> /dev/null); then
|
2011-05-31 11:46:26 +02:00
|
|
|
|
STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_RENAMED$STATUS"
|
|
|
|
|
fi
|
2011-06-08 17:33:29 +02:00
|
|
|
|
if $(echo "$INDEX" | grep '^M' &> /dev/null); then
|
2011-05-31 11:46:26 +02:00
|
|
|
|
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
|
2011-05-31 14:07:38 +02:00
|
|
|
|
|
2011-06-01 10:11:06 +02:00
|
|
|
|
if $(echo -n "$STATUS" | grep '.*' &> /dev/null); then
|
2011-05-31 14:07:38 +02:00
|
|
|
|
STATUS="$ZSH_THEME_GIT_STATUS_PREFIX$STATUS"
|
|
|
|
|
fi
|
|
|
|
|
|
2011-05-31 11:46:26 +02:00
|
|
|
|
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
|
2011-05-31 14:07:38 +02:00
|
|
|
|
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(git_prompt_ahead)$(custom_git_prompt_status)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
2011-05-31 11:46:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-07 15:28:43 +02:00
|
|
|
|
# %B sets bold text
|
2015-11-02 08:12:38 +01:00
|
|
|
|
PROMPT='%B$PROMPTPREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} '
|
2011-05-31 11:46:26 +02:00
|
|
|
|
RPS1="${return_code}"
|
|
|
|
|
|
2012-01-16 16:39:28 +01:00
|
|
|
|
ZSH_THEME_GIT_PROMPT_PREFIX="%{$Y%}‹"
|
|
|
|
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$Y%}›%{$RESET%} "
|
2011-05-31 11:46:26 +02:00
|
|
|
|
|
2011-05-31 14:07:38 +02:00
|
|
|
|
ZSH_THEME_GIT_PROMPT_DIRTY="%{$R%}*"
|
|
|
|
|
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
|
|
|
|
|
2012-01-16 16:39:28 +01:00
|
|
|
|
ZSH_THEME_GIT_PROMPT_AHEAD="%{$B%}➔"
|
|
|
|
|
|
2011-05-31 14:07:38 +02:00
|
|
|
|
|
|
|
|
|
ZSH_THEME_GIT_STATUS_PREFIX=" "
|
2011-05-31 11:46:26 +02:00
|
|
|
|
|
|
|
|
|
# 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
|
2012-01-16 16:39:28 +01:00
|
|
|
|
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}?"
|
2011-05-31 11:46:26 +02:00
|
|
|
|
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$R%}M"
|
|
|
|
|
ZSH_THEME_GIT_PROMPT_DELETED="%{$R%}D"
|
|
|
|
|
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$R%}UU"
|