Skip to content

Instantly share code, notes, and snippets.

@marcgg
Created May 9, 2012 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcgg/2644116 to your computer and use it in GitHub Desktop.
Save marcgg/2644116 to your computer and use it in GitHub Desktop.
Content for .zsh:
#########
# COLORS
#########
autoload -U colors
colors
setopt prompt_subst
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
# Text to display if the branch is dirty
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%} *%{$reset_color%}"
# Text to display if the branch is clean
ZSH_THEME_GIT_PROMPT_CLEAN=""
#########
# PROMPT
#########
PROMPT='%{$fg[cyan]%}${current_path}%{$fg[white]%}%{$fg[white]%}[$(~/bin/git-cwd-info)%{$reset_color%}] $ '
----------------
~[] $ cat ~/bin/git-cwd-info
GIT_REPO_PATH=`git rev-parse --git-dir 2>/dev/null`
if [[ $GIT_REPO_PATH != '' && $GIT_REPO_PATH != '~' && $GIT_REPO_PATH != "$HOME/.git" ]]; then
GIT_BRANCH=`git symbolic-ref -q HEAD | sed 's/refs\/heads\///'`
GIT_COMMIT_ID=`git rev-parse --short HEAD 2>/dev/null`
GIT_MODE=""
if [[ -e "$GIT_REPO_PATH/BISECT_LOG" ]]; then
GIT_MODE=" +bisect"
elif [[ -e "$GIT_REPO_PATH/MERGE_HEAD" ]]; then
GIT_MODE=" +merge"
elif [[ -e "$GIT_REPO_PATH/rebase" || -e "$GIT_REPO_PATH/rebase-apply" || -e "$GIT_REPO_PATH/rebase-merge" || -e "$GIT_REPO_PATH/../.dotest" ]]; then
GIT_MODE=" +rebase"
fi
GIT_DIRTY=""
if [[ "$GIT_REPO_PATH" != '.' && `git ls-files -m` != "" ]]; then
GIT_DIRTY=" %{%}✗%{%}"
fi
if [ $GIT_BRANCH = "master" ]; then
echo "%{%}$GIT_BRANCH$GIT_MODE$GIT_DIRTY"
elif [ $GIT_BRANCH = "development" ]; then
echo "%{%}$GIT_BRANCH$GIT_MODE$GIT_DIRTY"
else
echo "%{%}$GIT_BRANCH$GIT_MODE$GIT_DIRTY"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment