Skip to content

Instantly share code, notes, and snippets.

@dundee
Last active October 8, 2017 10:14
Show Gist options
  • Save dundee/3c82e54a52915887c6da26d887f10dd8 to your computer and use it in GitHub Desktop.
Save dundee/3c82e54a52915887c6da26d887f10dd8 to your computer and use it in GitHub Desktop.
Colorful bash prompt with git integration
if [[ ${EUID} == 0 ]]; then
PS1="\[\e[41;30m\] \w \${?/#0}\[\e[31;49m\]"$'\xee\x82\xb0'"\[\e[00m\] "
else
PS1="\[\e[44;30m\] \w \[\\e[31m\]\${?/#0}"
PS1="$PS1\$(\
export GIT_BRANCH=\"\$(git branch --no-color 2>/dev/null | sed -n 's/*[^ ]* //p')\"; \
if [ -n \"\$GIT_BRANCH\" ] ; then \
echo -en \"\[\e[43;34m\]\xee\x82\xb0 \"
echo -en \"\[\e[43;30m\]\$GIT_BRANCH \"
echo -en \"\[\e[33;49m\]\xee\x82\xb0\[\e[00m\] \"
else
echo -e \"\[\e[34;49m\]"$'\xee\x82\xb0'"\[\e[00m\] \"
fi \
)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment