Skip to content

Instantly share code, notes, and snippets.

@emaillenin
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emaillenin/0b59a781a82b822c1a6a to your computer and use it in GitHub Desktop.
Save emaillenin/0b59a781a82b822c1a6a to your computer and use it in GitHub Desktop.
my_bash_profile.sh
# 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