Created
November 3, 2009 18:58
-
-
Save martint/225321 to your computer and use it in GitHub Desktop.
This file contains 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
bash_prompt() { | |
local status=$(git status 2> /dev/null | grep 'working directory clean') | |
local dirty='' | |
if [ -z "$status" ]; then | |
local dirty='*' | |
fi | |
local branch=$(git branch 2> /dev/null | grep -e "\* " | sed "s/^..\(.*\)/\1/") | |
if [ -z "$branch" ]; then | |
export PS1="[$(date +%H:%M) \u@\[\033[33m\]\h\[\033[39m\]:\w] " | |
else | |
export PS1="[$(date +%H:%M) \u@\[\033[33m\]\h\[\033[39m\]:\w \[\033[32m\]$branch\[\033[36m\]$dirty\[\033[39m\]] " | |
fi | |
} | |
PROMPT_COMMAND=bash_prompt | |
cdgit() { | |
local gitdir=$(git rev-parse --git-dir) | |
if [ -n "$gitdir" ]; then | |
cd $(dirname $gitdir) | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment