blob: 949dcca4834477d08d7aee880c995cf68f0a545b [file] [log] [blame]
oddjobsman8c7b0792013-09-17 19:04:50 +05301# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt"
2# Screenshot: http://cloud.gf3.ca/M5rG
3# A big thanks to \amethyst on Freenode
4
5if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color
6elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color
7fi
8
9if tput setaf 1 &> /dev/null; then
10 tput sgr0
11 if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
12 MAGENTA=$(tput setaf 9)
13 ORANGE=$(tput setaf 172)
14 GREEN=$(tput setaf 190)
15 PURPLE=$(tput setaf 141)
16 WHITE=$(tput setaf 0)
17 else
18 MAGENTA=$(tput setaf 5)
19 ORANGE=$(tput setaf 4)
20 GREEN=$(tput setaf 2)
21 PURPLE=$(tput setaf 1)
22 WHITE=$(tput setaf 7)
23 fi
24 BOLD=$(tput bold)
25 RESET=$(tput sgr0)
26else
27 MAGENTA="\033[1;31m"
28 ORANGE="\033[1;33m"
29 GREEN="\033[1;32m"
30 PURPLE="\033[1;35m"
31 WHITE="\033[1;37m"
32 BOLD=""
33 RESET="\033[m"
34fi
35
36parse_git_dirty () {
37 [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*"
38}
39parse_git_branch () {
40 git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
41}
42
43PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"