#!/bin/bash # see # used http://bashrcgenerator.com/ # and # https://unix.stackexchange.com/questions/148/colorizing-your-terminal-and-shell-environment/174#174 function parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } function fancy_prompt () { # if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then function c () { local color name=COLOR_$1 color=${!name} echo '\['$color'\]' } case $TERM in xterm*|rxvt*) # local TITLEBAR='\[\033]0;\u ${NEW_PWD}\007\]' local PARENTBASE='${PWD#"${PWD%/*/*}/"}' ;; *) local PARENTBASE='' # local TITLEBAR="" ;; esac local UC=WHITE # user's color local MC=CYAN # machine color [[ $SSH_SESSION == "true" ]] && UC=LIGHT_PURPLE && MC=WHITE # remote machine color [ $UID -eq "0" ] && UC=LIGHT_RED # root's color # PS1="$PARENTBASE\[${UC}\]\u@\h: \[${COLOR_LIGHT_GREEN}\]→\[${COLOR_NC}\] " local user local machine local dir local branch local promptc user="$(c $UC)\u$(c GREY)@$(c NC)" machine="$(c $MC)\h$(c GREY):$(c NC)" dir="$(c YELLOW)[${PARENTBASE}]$(c NC)" branch=$(c LIGHT_BLUE)'$(parse_git_branch)'$(c NC) promptc=$(c GREEN)' $ '$(c NC) PS1=$(echo "$user$machine$dir$branch$promptc") # echo $PS1 } # fancy prompt is on by default comment out to disable default fancy_prompt