Skip to content

Instantly share code, notes, and snippets.

@jamyouss

jamyouss/bash_prompt

Created Jul 20, 2016
Embed
What would you like to do?
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