Last active
October 5, 2017 05:37
-
-
Save kijtra/16b6f0063c85d0f673d9a0a80c81939a to your computer and use it in GitHub Desktop.
Bash color like Windows Git Bash
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 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