Commits

Vasyl Nakvasiuk committed f604063

add .bash_prompt

  • Participants
  • Parent commits 76c5cd2

Comments (0)

Files changed (3)

File .bash_profile

 # Load extra files from ~./extra: .local, .exports, .aliases, .functions
 # ~/.extra/.local can be used for settings you don’t want to commit
-for file in ~/.extra/.{exports,aliases,functions,local}; do
+for file in ~/.extra/.{exports,aliases,functions,bash_prompt,local}; do
     [ -r "$file" ] && source "$file"
 done
 unset file

File .extra/.bash_prompt

+function __set_prompt
+{
+    if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
+        export TERM=gnome-256color
+    elif infocmp xterm-256color >/dev/null 2>&1; then
+        export TERM=xterm-256color
+    fi
+
+    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)/"
+    }
+
+    # Configure Colors:
+    WHITE='\033[1;37m'
+    LIGHTGRAY='033[0;37m'
+    GRAY='\033[1;30m'
+    BLACK='\033[0;30m'
+    RED='\033[0;31m'
+    LIGHTRED='\033[1;31m'
+    GREEN='\033[0;32m'
+    LIGHTGREEN='\033[1;32m'
+    BROWN='\033[0;33m'
+    YELLOW='\033[1;33m'
+    BLUE='\033[0;34m'
+    LIGHTBLUE='\033[1;34m'
+    PURPLE='\033[0;35m'
+    PINK='\033[1;35m'
+    CYAN='\033[0;36m'
+    LIGHTCYAN='\033[1;36m'
+    DEFAULT='\033[0m'
+    MAGENTA='\033[1;31m'
+    ORANGE='\033[1;33m'
+
+    export PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$CYAN\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]${DEFAULT}"
+}
+
+__set_prompt

File bootstrap.sh

 cd "$(dirname "$0")"
 
 function doIt() {
-	rsync --exclude ".git/" --exclude ".DS_Store" --exclude "bootstrap.sh" --exclude "README.rst" -av . ~
+    rsync --exclude ".git/" --exclude ".DS_Store" --exclude "bootstrap.sh" --exclude "README.rst" -av . ~
 }
 if [ "$1" == "--force" -o "$1" == "-f" ]; then
-	doIt
+    doIt
 else
-	read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1
-	echo
-	if [[ $REPLY =~ ^[Yy]$ ]]; then
-		doIt
-	fi
+    read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1
+    echo
+    if [[ $REPLY =~ ^[Yy]$ ]]; then
+        doIt
+    fi
 fi
 unset doIt
 source ~/.bash_profile