Created
July 20, 2016 12:53
-
-
Save jamyouss/fa1f7484726c781c6844ad54d569b432 to your computer and use it in GitHub Desktop.
Custom bash prompt with git and syntax coloration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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