Created
February 21, 2012 18:56
-
-
Save geothird/1878135 to your computer and use it in GitHub Desktop.
Bash git completion and ps1 status/dirty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Git bash completion scripts | |
## | |
if [ -f /usr/local/git/contrib/completion/git-completion.bash ]; then | |
# Git OS X Installer: http://code.google.com/p/git-osx-installer/ | |
. /usr/local/git/contrib/completion/git-completion.bash | |
elif type brew > /dev/null 2>&1 && [ -f `brew --prefix`/etc/bash_completion ]; then | |
# Homebrew: http://mxcl.github.com/homebrew/ | |
. `brew --prefix`/etc/bash_completion | |
elif [ -f /opt/local/etc/bash_completion.d/git ]; then | |
# MacPorts: http://www.macports.org/ | |
. /opt/local/etc/bash_completion.d/git | |
fi | |
## | |
# Shell colors | |
## | |
BLACK="\[\e[0;30m\]" BOLD_BLACK="\[\e[1;30m\]" UNDER_BLACK="\[\e[4;30m\]" | |
RED="\[\e[0;31m\]" BOLD_RED="\[\e[1;31m\]" UNDER_RED="\[\e[4;31m\]" | |
GREEN="\[\e[0;32m\]" BOLD_GREEN="\[\e[1;32m\]" UNDER_GREEN="\[\e[4;32m\]" | |
YELLOW="\[\e[0;33m\]" BOLD_YELLOW="\[\e[1;33m\]" UNDER_YELLOW="\[\e[4;33m\]" | |
BLUE="\[\e[0;34m\]" BOLD_BLUE="\[\e[1;34m\]" UNDER_BLUE="\[\e[4;34m\]" | |
PURPLE="\[\e[0;35m\]" BOLD_PURPLE="\[\e[1;35m\]" UNDER_PURPLE="\[\e[4;35m\]" | |
CYAN="\[\e[0;36m\]" BOLD_CYAN="\[\e[1;36m\]" UNDER_CYAN="\[\e[4;36m\]" | |
WHITE="\[\e[0;37m\]" BOLD_WHITE="\[\e[1;37m\]" UNDER_WHITE="\[\e[4;37m\]" | |
NO_COLOR="\[\e[0m\]" | |
## | |
# Git shell prompt | |
## | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' | |
} | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
export PS1="${BOLD_RED}\h${WHITE}[${GREEN}\W${WHITE}]${WHITE}[${CYAN}\$(parse_git_branch)${RED}\$(parse_git_dirty)${WHITE}]${NO_COLOR} " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment