Last active
August 29, 2015 14:09
-
-
Save white-gecko/9f1f209d91772d6eee50 to your computer and use it in GitHub Desktop.
My zsh theme (you have to place it in ~/.oh-my-zsh/themes/ and change ZSH_THEME to gecko in your .zshrc)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this theme was build be taking some code and impressions from mortalscumbag, intheloop, crcandy and bureau | |
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 () { | |
_INDEX=$(command git status --porcelain -b 2> /dev/null) | |
_STATUS="" | |
if $(echo "$_INDEX" | grep '^[AMRD]. ' &> /dev/null); then | |
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED" | |
fi | |
if $(echo "$_INDEX" | grep '^.[MTD] ' &> /dev/null); then | |
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" | |
fi | |
if $(echo "$_INDEX" | grep -E '^\?\? ' &> /dev/null); then | |
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED" | |
fi | |
if $(echo "$_INDEX" | 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" | grep '^## .*ahead' &> /dev/null); then | |
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD" | |
fi | |
if $(echo "$_INDEX" | grep '^## .*behind' &> /dev/null); then | |
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND" | |
fi | |
if $(echo "$_INDEX" | grep '^## .*diverged' &> /dev/null); then | |
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED" | |
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 | |
} | |
local ret_status="%(?::%{$fg[red]%} [%{$fg[yellow]%}⚡%?%{$fg[red]%}]%{$reset_color%})" | |
PROMPT=$' | |
%{$fg[green]%}%n@%m %{$fg[blue]%}[%*] %{$reset_color%}%{$fg[white]%}[%~]%{$reset_color%}${ret_status} $(bureau_git_prompt)\ | |
%{$fg_bold[blue]%} %{$reset_color%}' | |
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[ " | |
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[cyan]%}▴" | |
ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[magenta]%}▾" | |
ZSH_THEME_GIT_PROMPT_DIVERGED="%{$fg[magenta]%}" | |
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[green]%}" | |
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg[red]%}" | |
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}●" | |
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[red]%}✕" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}%{$fg[green]%}]%{$reset_color%}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment