Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nathanjackson/903e42415b0cb5bb905ff7af4e1cd25b to your computer and use it in GitHub Desktop.
Save nathanjackson/903e42415b0cb5bb905ff7af4e1cd25b to your computer and use it in GitHub Desktop.
my PS1 variable
function git_portion {
git status > /dev/null 2> /dev/null
if [[ $? -eq 0 ]]
then
current_branch=$(git rev-parse --abbrev-ref HEAD)
modified='\e[92m'
git diff --exit-code 2>/dev/null >/dev/null
if [[ $? -ne 0 ]]
then
modified='\e[97m*\e[93m'
fi
printf ' \e[0m\e[96m(%b%s\e[96m)' $modified $current_branch
fi
}
export PS1='\[\e[96m\][\[\e[97m\]\w$(git_portion)\[\e[96m\]]\n\[\e[97m\]\u@\h \[\e[91m\]\!\[\e[96m\]\$> \[\e[0m\]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment