7May/180
colorful bash prompt with git branch
Edit .bashrc
:
export COLOR_NC='\e[0m' # No Color export COLOR_WHITE='\e[1;37m' export COLOR_BLACK='\e[0;30m' export COLOR_BLUE='\e[0;34m' export COLOR_LIGHT_BLUE='\e[1;34m' export COLOR_GREEN='\e[0;32m' export COLOR_LIGHT_GREEN='\e[1;32m' export COLOR_CYAN='\e[0;36m' export COLOR_LIGHT_CYAN='\e[1;36m' export COLOR_RED='\e[0;31m' export COLOR_LIGHT_RED='\e[1;31m' export COLOR_PURPLE='\e[0;35m' export COLOR_LIGHT_PURPLE='\e[1;35m' export COLOR_BROWN='\e[0;33m' export COLOR_YELLOW='\e[1;33m' export COLOR_GRAY='\e[0;30m' export COLOR_LIGHT_GRAY='\e[0;37m' function parse_git_dirty { [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*" } function parse_git_branch { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" } PS1="" PS1=$PS1"\[$COLOR_GREEN\]\u@\h\:" # Display user@host #PS1=$PS1"\[$Yellow\]\@:" # Display time #PS1=$PS1"\[$Blue\][\[$Cyan\]\d\[$Blue\]] " # Display date #PS1=$PS1"\[$Yellow\]\@:" # Display time PS1=$PS1"\[$COLOR_CYAN\]\w" # Display pwd PS1=$PS1"\[$COLOR_BROWN\]"'$(parse_git_branch)' # Display git-branch PS1=$PS1"\[$COLOR_NC\]$ " # Turn off color and end prompt export PS1=$PS1