Skip to content

Instantly share code, notes, and snippets.

@supermitsuba
Created December 6, 2015 00:37
Show Gist options
  • Save supermitsuba/c8d5d0299d65bbcd689f to your computer and use it in GitHub Desktop.
Save supermitsuba/c8d5d0299d65bbcd689f to your computer and use it in GitHub Desktop.
#git prompt
COLOR_RED="\033[0;31m"
COLOR_YELLOW="\033[0;33m"
COLOR_GREEN="\033[0;32m"
COLOR_OCHRE="\033[38;5;95m"
COLOR_BLUE="\033[0;34m"
COLOR_WHITE="\033[0;37m"
COLOR_RESET="\033[0m"
git_color()
{
local git_status="$(git status 2> /dev/null)"
if [[ ! $git_status =~ "working directory clean" ]];
then
echo -e $COLOR_RED
elif [[ $git_status =~ "Your branch is ahead of" ]];
then
echo -e $COLOR_YELLOW
elif [[ $git_status =~ "nothing to commit" ]];
then
echo -e $COLOR_GREEN
else
echo -e $COLOR_RESET
fi
}
git_branch()
{
local git_status="$(git status 2> /dev/null)"
local on_branch="On branch ([^${IFS}]*)"
local on_commit="HEAD detached at ([^${IFS}]*)"
if [[ $git_status =~ $on_branch ]]; then
local branch=${BASH_REMATCH[1]}
echo "($branch) ๐ŸŒž "
elif [[ $git_status =~ $on_commit ]]; then
local commit=${BASH_REMATCH[1]}
echo "($commit) ๐Ÿ‘พ "
fi
}
# ๐Ÿฅ๐Ÿ๐ŸŒฒ๐Ÿฒ๐ŸŒœ๐ŸŒžโ˜๏ธ๐Ÿš๐Ÿšด๐ŸŽฎ๐Ÿ‘พ ๐Ÿป ๐Ÿ•
PS1="\n๐ŸŒฒ \u ๐ŸŒฒ \w"
PS1+="\[\$(git_color)\]"
PS1+=" ๐ŸŒฒ \$(git_branch) "
PS1+="$COLOR_RESET \n๐Ÿ’ฉ >"
export PS1
export PS1+=" "
export SUDO_PS1="Sudo "+PS1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment