Last active
August 29, 2015 14:01
-
-
Save emaillenin/0b59a781a82b822c1a6a to your computer and use it in GitHub Desktop.
my_bash_profile.sh
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
# Inspired from https://gist.github.com/selvakn/358558 | |
export HISTORYFILESIZE=10000 | |
export PS_COLOR="0;32" | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /' | |
} | |
is_git_dir() { | |
git status > /dev/null 2> /dev/null | |
if [ $? -eq 128 ] | |
then | |
return 1 | |
else | |
return 0 | |
fi | |
} | |
parse_git_dirty() { | |
git status 2> /dev/null | tail -n1 | grep "working directory clean" > /dev/null | |
dirty=$? | |
if is_git_dir | |
then | |
if [ $dirty -eq 0 ] | |
then | |
echo "$" | |
else | |
echo "⚡" | |
fi | |
else | |
echo "$" | |
fi | |
} | |
export PS1="\[\e[${PS_COLOR}m\]\w \[\e[0;39m\]\$(parse_git_branch)\$(parse_git_dirty) " | |
# Useful aliases | |
alias ll='ls -ltrh' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment