Commits

Carl Meyer  committed 970ebc1

Added nicer bash prompt.

  • Participants
  • Parent commits 3e7f85b

Comments (0)

Files changed (3)

File .bash_custom

 
 alias ec="emacsclient -n"
 alias ipython="python -c 'import IPython; IPython.Shell.IPShell().mainloop()'"
-alias killpyc="find . -iname '*.pyc' -delete"
-alias killbak="find . -iname '*~' -delete"
+alias rmpyc="find . -iname '*.pyc' -delete"
+alias rmbak="find . -iname '*~' -delete"
 
 mktags() {
     PWD=`pwd`
     SP=`virtualenvwrapper_get_site_packages_dir`
     find $PWD $SP -name '*.py' | etags -
 }
+
+source ~/dot/.bash_prompt

File .bash_prompt

+#
+# Colorized prompt bash prompt with goodies
+# from https://github.com/bitprophet/dotfiles/blob/master/.bash_prompt
+#
+
+# Color codes
+RED='\[\033[01;31m\]'
+GREEN='\[\033[01;32m\]'
+YELLOW='\[\033[01;33m\]'
+BLUE='\[\033[01;34m\]'
+PURPLE='\[\033[01;35m\]'
+CYAN='\[\033[01;36m\]'
+WHITE='\[\033[01;37m\]'
+NIL='\[\033[00m\]'
+
+# Hostname styles
+FULL='\H'
+SHORT='\h'
+
+# System => color/hostname map:
+# UC: username color
+# LC: location/cwd color
+# HD: hostname display (\h vs \H)
+# Defaults:
+UC=$GREEN
+LC=$BLUE
+HD=$SHORT
+
+HOST=`hostname | cut -d '.' -f 1`
+DOMAIN=`hostname | cut -d '.' -f 2-`
+
+
+# Prompt function because PROMPT_COMMAND is awesome
+function set_prompt() {
+    host="${UC}${HD}${NIL}"
+
+    # Special vim-tab-like shortpath (~/folder/directory/foo => ~/f/d/foo)
+    _pwd=`pwd | sed "s#$HOME#~#"`
+    if [[ $_pwd == "~" ]]; then
+        _dirname=$_pwd
+    else
+        _dirname=`dirname "$_pwd" #| sed -E "s/\/(.)[^\/]*/\/\1/g"`
+        if [[ $_dirname == "/" ]]; then
+            _dirname=""
+        fi
+        _dirname="$_dirname/`basename "$_pwd"`"
+    fi
+    path="${LC}${_dirname}${NIL}"
+
+    # Virtualenv
+    _venv=`basename "$VIRTUAL_ENV"`
+    venv="" # need this to clear it when we leave a venv
+    if [[ -n $_venv ]]; then
+        venv=" ${NIL}{${PURPLE}${_venv}${NIL}}"
+    fi
+
+    # Git branch / dirtiness
+    # Dirtiness cribbed from:
+    # http://henrik.nyh.se/2008/12/git-dirty-prompt#comment-8325834
+    if git update-index -q --refresh 2>/dev/null; git diff-index --quiet --cached HEAD --ignore-submodules -- 2>/dev/null && git diff-files --quiet --ignore-submodules 2>/dev/null
+        then dirty=""
+    else
+        dirty="${RED}*${NIL}"
+    fi
+    _branch=$(git symbolic-ref HEAD 2>/dev/null)
+    _branch=${_branch#refs/heads/} # apparently faster than sed
+    branch="" # need this to clear it when we leave a repo
+    if [[ -n $_branch ]]; then
+        branch=" ${NIL}[${PURPLE}${_branch}${dirty}${NIL}]"
+    fi
+
+    # Dollar/pound sign
+    end="\n${LC}\$${NIL} "
+
+    # Time (useful when catting logs)
+    time="[${GREEN}$(date +"%R")${NIL}]"
+
+    # user
+    user="${CYAN}${USER}${NIL}"
+
+    # Put it all together
+    export PS1="\n${time} ${user}@${host}:${path}${venv}${branch} ${end}"
+}
+export PROMPT_COMMAND=set_prompt
-fc49f48d28e5818881358c8341e8a5acfe7f5aed .emacs.d/lintnode
-39f1abc8915235c36b07307430162f577b57389d hgext/crecord
-d27379c0abde5e12346cb6e8d28f165800e41219 hgext/hg-git
+82cff7dc3258fdf9c24735967fdfce62f05321dd .emacs.d/lintnode
+a3518e68d5e2046864bf412c794e60b6a9f50182 hgext/crecord
+3f45c88100e85c9297f55b9097315582f4249ffd hgext/hg-git
 f7b2308a7cd6c105f6b82bb660bb345bdd9b05d9 hgext/hgcollapse
 cc79e0f5c9b3bdb3d3f37a7a8a295f9798f48806 hgext/hgshelve
 2ddb95cd36dd879953ad866622e917c96d9b3e73 hgext/hgsubversion