Skip to content

Instantly share code, notes, and snippets.

@anamartinez
Created October 6, 2012 03:07
Show Gist options
  • Save anamartinez/3843626 to your computer and use it in GitHub Desktop.
Save anamartinez/3843626 to your computer and use it in GitHub Desktop.
Make your git promp look cool
git_prompt (){
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
if git diff --quiet 2>/dev/null >&2; then
git_color="\[\e[0;37m\]" # git clean
else
git_color="\[\e[0;31m\]" # git dirty
fi
echo " \[\e[0;36m\[[$git_color$git_branch\[\e[0;36m\]]"
}
normal_text(){
echo "\[\033[m\]"
}
start_of_prompt(){
BOLD="\[\033[1m\]"
OFF="\[\033[m\]"
BLUE="\[\e[34;1m\]"
RED_UNDERLINED="\e[4;31m"
echo "${RED_UNDERLINED}\u${OFF} in ${BLUE}\W${OFF}"
}
second_line_prompt(){
ARROW='↳'
echo "\n${ARROW} "
}
PROMPT_COMMAND='PS1="$(start_of_prompt)$(git_prompt) $(normal_text)$(second_line_prompt)"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment