Skip to content

@courtneyfaulkner /gist:235332 forked from matthewmccullough/gist:47267
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Show Git dirty status in your Unix bash prompt, show ls color, simple tree
#!/bin/sh
source /usr/local/etc/bash_completion.d/git-completion.bash
source /usr/local/etc/bash_completion.d/git-flow-completion.bash
source /usr/local/etc/bash_completion.d/git-prompt.sh
export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256"
export CLICOLOR=1
BLACK="\[\033[0;0m\]"
BLUE="\[\033[0;34m\]"
BROWN="\[\033[0;33m\]"
COLOR_NONE="\[\e[0m\]"
CYAN="\[\033[0;36m\]"
GREEN="\[\033[0;32m\]"
LIGHT_GRAY="\[\033[1;37m\]"
LIGHT_GREEN="\[\033[1;32m\]"
LIGHT_RED="\[\033[1;31m\]"
PURPLE="\[\033[0;35m\]"
RED="\[\033[0;31m\]"
WHITE="\[\033[0;37m\]"
YELLOW="\[\033[0;33m\]"
function tree {
find ${1:-.} -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
}
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
#GIT_PS1_SHOWUPSTREAM="auto"
function prompt_func() {
previous_return_value=$?;
TITLEBAR='\[\e]2;\w\a\]'
prompt="${TITLEBAR}${PURPLE}\u@\h ${BLUE}\W${GREEN}$(__git_ps1)${COLOR_NONE} "
if test $previous_return_value -eq 0
then
PS1="${prompt}\$ "
else
PS1="${prompt}${RED}\$${COLOR_NONE} "
fi
}
PROMPT_COMMAND=prompt_func
@courtneyfaulkner

OS X

Create/add/replace your ~/.bash_profile with the contents from above. The /usr/local/etc/bash_completion.d/git-completion.bash script is installed with git when you install git with brew (http://mxcl.github.com/homebrew/).

Linux

Using the above in your ~/.bash_profile should work, but you'll need to install the git-completion.bash script from https://github.com/git/git/blob/master/contrib/completion/git-completion.bash.

Windows

I haven't tested it, but following the Linux instructions in Cygwin should/might work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.