Skip to content

Instantly share code, notes, and snippets.

@jamyouss
Created July 20, 2016 12:53
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 jamyouss/fa1f7484726c781c6844ad54d569b432 to your computer and use it in GitHub Desktop.
Save jamyouss/fa1f7484726c781c6844ad54d569b432 to your computer and use it in GitHub Desktop.
Custom bash prompt with git and syntax coloration
source /usr/local/etc/bash_completion.d/git-prompt.sh
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
function prompt_cmd() {
previous_return_value=$?;
prompt="${RED}\u@\h ❯ ${YELLOW}\w${BLUE}$(__git_ps1)"
if test $previous_return_value -eq 0
then
PS1="${prompt}${LIGHT_GRAY} ❯ "
else
PS1="${prompt}${RED} ❯ ${LIGHT_GRAY}"
fi
}
PROMPT_COMMAND=prompt_cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment