2013-11-08 19:26:25 +00:00
|
|
|
# oh-my-zsh Bureau Theme
|
|
|
|
|
|
|
|
### NVM
|
|
|
|
|
|
|
|
ZSH_THEME_NVM_PROMPT_PREFIX="%B⬡%b "
|
|
|
|
ZSH_THEME_NVM_PROMPT_SUFFIX=""
|
|
|
|
|
|
|
|
### Git [±master ▾●]
|
|
|
|
|
|
|
|
ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg_bold[green]%}±%{$reset_color%}%{$fg_bold[white]%}"
|
|
|
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}]"
|
|
|
|
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓%{$reset_color%}"
|
|
|
|
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[cyan]%}▴%{$reset_color%}"
|
|
|
|
ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[magenta]%}▾%{$reset_color%}"
|
|
|
|
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}"
|
|
|
|
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
|
|
|
|
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
|
|
|
|
|
|
|
|
bureau_git_branch () {
|
|
|
|
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
|
|
|
|
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
|
|
|
|
echo "${ref#refs/heads/}"
|
|
|
|
}
|
|
|
|
|
|
|
|
bureau_git_status () {
|
|
|
|
_STATUS=""
|
2014-04-25 22:44:02 +00:00
|
|
|
if [[ $(command git status --short 2> /dev/null) != "" ]]; then
|
|
|
|
_INDEX=$(command git status --porcelain -b 2> /dev/null)
|
|
|
|
if $(echo "$_INDEX" | command grep '^[AMRD]. ' &> /dev/null); then
|
|
|
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
|
|
|
|
fi
|
|
|
|
if $(echo "$_INDEX" | command grep '^.[MTD] ' &> /dev/null); then
|
|
|
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
|
|
|
|
fi
|
|
|
|
if $(echo "$_INDEX" | command grep -E '^\?\? ' &> /dev/null); then
|
|
|
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
|
|
|
|
fi
|
|
|
|
if $(echo "$_INDEX" | command grep '^UU ' &> /dev/null); then
|
|
|
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
|
|
|
|
fi
|
|
|
|
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
|
|
|
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
|
|
|
|
fi
|
|
|
|
if $(echo "$_INDEX" | command grep '^## .*ahead' &> /dev/null); then
|
|
|
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
|
|
|
|
fi
|
|
|
|
if $(echo "$_INDEX" | command grep '^## .*behind' &> /dev/null); then
|
|
|
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
|
|
|
|
fi
|
|
|
|
if $(echo "$_INDEX" | command grep '^## .*diverged' &> /dev/null); then
|
|
|
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
|
2013-11-08 19:26:25 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo $_STATUS
|
|
|
|
}
|
|
|
|
|
|
|
|
bureau_git_prompt () {
|
|
|
|
local _branch=$(bureau_git_branch)
|
|
|
|
local _status=$(bureau_git_status)
|
|
|
|
local _result=""
|
|
|
|
if [[ "${_branch}x" != "x" ]]; then
|
|
|
|
_result="$ZSH_THEME_GIT_PROMPT_PREFIX$_branch"
|
|
|
|
if [[ "${_status}x" != "x" ]]; then
|
|
|
|
_result="$_result $_status"
|
|
|
|
fi
|
|
|
|
_result="$_result$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
|
|
|
fi
|
|
|
|
echo $_result
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_PATH="%{$fg_bold[white]%}%~%{$reset_color%}"
|
|
|
|
|
2014-01-03 13:43:31 +00:00
|
|
|
if [[ $EUID -eq 0 ]]; then
|
2013-11-08 19:26:25 +00:00
|
|
|
_USERNAME="%{$fg_bold[red]%}%n"
|
|
|
|
_LIBERTY="%{$fg[red]%}#"
|
|
|
|
else
|
|
|
|
_USERNAME="%{$fg_bold[white]%}%n"
|
|
|
|
_LIBERTY="%{$fg[green]%}$"
|
|
|
|
fi
|
|
|
|
_USERNAME="$_USERNAME%{$reset_color%}@%m"
|
|
|
|
_LIBERTY="$_LIBERTY%{$reset_color%}"
|
|
|
|
|
|
|
|
|
|
|
|
get_space () {
|
|
|
|
local STR=$1$2
|
|
|
|
local zero='%([BSUbfksu]|([FB]|){*})'
|
2014-04-25 22:44:02 +00:00
|
|
|
local LENGTH=${#${(S%%)STR//$~zero/}}
|
2013-11-08 19:26:25 +00:00
|
|
|
local SPACES=""
|
|
|
|
(( LENGTH = ${COLUMNS} - $LENGTH - 1))
|
2014-04-25 22:44:02 +00:00
|
|
|
|
2013-11-08 19:26:25 +00:00
|
|
|
for i in {0..$LENGTH}
|
|
|
|
do
|
|
|
|
SPACES="$SPACES "
|
|
|
|
done
|
|
|
|
|
|
|
|
echo $SPACES
|
|
|
|
}
|
|
|
|
|
|
|
|
_1LEFT="$_USERNAME $_PATH"
|
|
|
|
_1RIGHT="[%*] "
|
|
|
|
|
|
|
|
bureau_precmd () {
|
|
|
|
_1SPACES=`get_space $_1LEFT $_1RIGHT`
|
2014-04-25 22:44:02 +00:00
|
|
|
print
|
2014-03-10 23:36:51 +00:00
|
|
|
print -rP "$_1LEFT$_1SPACES$_1RIGHT"
|
2013-11-08 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setopt prompt_subst
|
2014-03-10 23:36:51 +00:00
|
|
|
PROMPT='> $_LIBERTY '
|
2013-11-08 19:26:25 +00:00
|
|
|
RPROMPT='$(nvm_prompt_info) $(bureau_git_prompt)'
|
|
|
|
|
|
|
|
autoload -U add-zsh-hook
|
|
|
|
add-zsh-hook precmd bureau_precmd
|