public
Last active — forked from matthewmccullough/gist:47267

Show Git dirty status in your Unix bash prompt, show ls color, simple tree

  • Download Gist
gistfile1.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#!/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

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.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.