Skip to content

Instantly share code, notes, and snippets.

@michimani
Created March 2, 2018 00:28
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 michimani/1ae09ef9c6743b31b49ea7a1d211ddc2 to your computer and use it in GitHub Desktop.
Save michimani/1ae09ef9c6743b31b49ea7a1d211ddc2 to your computer and use it in GitHub Desktop.
Coloring text and displaying git branch for bash prompt
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'
}
function promps {
local BLUE="\[\e[34m\]"
local RED="\[\e[31m\]"
local GREEN="\[\e[32m\]"
local WHITE="\[\e[00m\]"
local GRAY="\[\e[37m\]"
local MAGENTA="\[\e[35m\]"
local YELLOW="\[\e[33m\]"
local BRANCH=$YELLOW
PS1="\n${GREEN}\u \[\e[1m\]${BLUE}\w\[\e[0m\] ${BRANCH}\$(parse_git_branch) \[\e[0m\]\n\[\e[1m\]${MAGENTA}> \[\e[0m\]"
}
promps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment