Skip to content

Instantly share code, notes, and snippets.

@smreed
Created July 30, 2009 16:10
Show Gist options
  • Save smreed/158758 to your computer and use it in GitHub Desktop.
Save smreed/158758 to your computer and use it in GitHub Desktop.
export MAVEN_OPTS="-server -Xmx1g -Xms64m"
export SVN_EDITOR="mate -w"
export HISTCONTROL=erasedups
export HISTSIZE=10000
shopt -s histappend
# git status with a dirty flag
function __git_status_flag {
git_status="$(git status 2> /dev/null)"
remote_pattern="^# Your branch is (.*) of"
diverge_pattern="# Your branch and (.*) have diverged"
if [[ ! ${git_status}} =~ "working directory clean" ]]; then
state="⚡"
spacer=" "
fi
if [[ ${git_status} =~ ${remote_pattern} ]]; then
spacer=" "
if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then
remote="↑"
else
remote="↓"
fi
fi
if [[ ${git_status} =~ ${diverge_pattern} ]]; then
remote="↕"
spacer=" "
fi
echo "${state}${remote}${spacer}"
}
# the prompt itself
PS1='\[\e[1;34m\]\w\[\e[22;35m\]$(__git_ps1 " [\[\e[33m\]$(__git_status_flag)\[\e[35m\]%s]")\[\e[33m\] \$ \[\e[0m\]'
export MAVEN_OPTS="-server -Xmx1g -Xms64m"
export SVN_EDITOR="mate -w"
export HISTCONTROL=erasedups
export HISTSIZE=10000
shopt -s histappend
# Combining Lachie Cox's crazy Git branch mojo:
# http://spiral.smartbomb.com.au/post/31418465
# with
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# AND Geoff Grosenbach's style:
# http://pastie.org/325104
# Sweeeeeeeet!
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "(?<98>?)"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
export PS1='\[\033[01;32m\]\w $(git branch &>/dev/null; if [ $? -eq 0 ];
then echo "\[\033[01;34m\]$(parse_git_branch)"; fi) \$ \[\033[00m\]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment