Skip to content

Instantly share code, notes, and snippets.

@tdomzal
Last active August 29, 2015 14:21
Show Gist options
  • Save tdomzal/0dc8bc6f6a5a4da9d1ca to your computer and use it in GitHub Desktop.
Save tdomzal/0dc8bc6f6a5a4da9d1ca to your computer and use it in GitHub Desktop.
git enabled bash prompt setup
#!/bin/bash
# git prompt inspired by:
# http://neverstopbuilding.com/gitpro
# colors help:
# http://misc.flogisoft.com/bash/tip_colors_and_formatting
if [ "$1" == "install" ] ; then
WGET_PATH=$(which wget)
if [ ! -x "$WGET_PATH" ] ; then
>&2 echo "wget not found: unable to install"
exit 1
fi
wget -O .git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
chmod 755 ~/.git-completion.bash
wget -O .git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
chmod 755 ~/.git-prompt.sh
fi
source ~/.git-completion.bash
source ~/.git-prompt.sh
DEFAULT="\[\033[0;39m\]"
MAGENTA="\[\033[0;35m\]"
LIGHT_MAGENTA="\[\033[0;95m\]"
YELLOW="\[\033[0;33m\]"
BLUE="\[\033[34m\]"
LIGHT_BLUE="\[\033[94m\]"
LIGHT_GRAY="\[\033[0;37m\]"
CYAN="\[\033[0;36m\]"
GREEN="\[\033[0;32m\]"
GIT_PS1_SHOWDIRTYSTATE=true
export LS_OPTIONS='--color=auto'
export CLICOLOR='Yes'
export LSCOLORS=gxfxbEaEBxxEhEhBaDaCaD
export PS1=$LIGHT_GRAY"\u@\h:"'$(
if [[ $(__git_ps1) =~ \*\)$ ]]
# a file has been modified but not added
then echo "'$YELLOW'"$(__git_ps1 " (%s)")
elif [[ $(__git_ps1) =~ \+\)$ ]]
# a file has been added, but not commited
then echo "'$LIGHT_MAGENTA'"$(__git_ps1 " (%s)")
# the state is clean, changes are commited
else echo "'$CYAN'"$(__git_ps1 " (%s)")
fi)'$LIGHT_BLUE" \w\$"$DEFAULT" "
alias ll='ls -lah'
alias gst='git status -s'
cd
wget https://gist.githubusercontent.com/tdomzal/0dc8bc6f6a5a4da9d1ca/raw/085e7b65eebaec116c21412e5b27965256104139/.bash_profile
. .bash_profile install
# logout & login to activate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment