Created
March 2, 2018 00:28
-
-
Save michimani/1ae09ef9c6743b31b49ea7a1d211ddc2 to your computer and use it in GitHub Desktop.
Coloring text and displaying git branch for bash prompt
This file contains 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
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