Skip to content

Instantly share code, notes, and snippets.

@kijtra
Last active October 5, 2017 05:37
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 kijtra/16b6f0063c85d0f673d9a0a80c81939a to your computer and use it in GitHub Desktop.
Save kijtra/16b6f0063c85d0f673d9a0a80c81939a to your computer and use it in GitHub Desktop.
Bash color like Windows Git Bash
function show_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/'
}
function show_colored_prompt {
local WHITE="\[\e[00m\]"
local GRAY="\[\e[1;30m\]"
local LIGHTGREEN="\[\e[1;32m\]"
local GREEN="\[\e[0;32m\]"
local PURPLE="\[\e[0;35m\]"
local YELLOW="\[\e[0;33m\]"
local CYAN="\[\e[0;36m\]"
local MARK="\$"
if [[ $EUID -eq 0 ]]; then
MARK="#"
fi
PS1="\n${LIGHTGREEN}\u${GREEN}@\h ${YELLOW}\w${CYAN}\$(show_git_branch)${WHITE}\n${PURPLE}${MARK}${WHITE} "
case $TERM in
kterm|xterm|mlterm|cygwin|vt102)
PS1="\[\e]0;\u@\h: \w\]${PS1}"
;;
esac
}
show_colored_prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment