Last active
September 16, 2018 16:58
-
-
Save bylatt/4971506 to your computer and use it in GitHub Desktop.
My .bash_profile setup on OS X. Modified from Mark Otto's bash style (http://markdotto.com/2013/01/13/improved-terminal-hotness/) by adding git color for status.
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
alias ls='ls -Glah' | |
alias web='open -a Safari.app' | |
alias mail='open -a Mail.app' | |
alias todo='open -a Reminders.app' | |
git_branch () { | |
if git rev-parse --git-dir >/dev/null 2>&1 | |
then echo -e "" [$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')] | |
else | |
echo "" | |
fi | |
} | |
function git_color { | |
local STATUS=`git status 2>&1` | |
if [[ "$STATUS" == *'Not a git repository'* ]] | |
then echo "" | |
else | |
if [[ "$STATUS" != *'working directory clean'* ]] | |
then | |
# red if need to commit | |
echo -e '\033[0;31m' | |
else | |
if [[ "$STATUS" == *'Your branch is ahead'* ]] | |
then | |
# yellow if need to push | |
echo -e '\033[0;33m' | |
else | |
# else cyan | |
echo -e '\033[0;32m' | |
fi | |
fi | |
fi | |
} | |
export PS1='\[\033[0;35m\]⌘ \[\033[0;34m\]\w/\[$(git_color)\]$(git_branch)\[\033[m\] ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to one of the git release notes:
So pretty much git status will now say working tree instead of working directory. Line 17 should be updated to reflect that, or else it will always be false.