diff .bash_overrides @ 0:f3ab51c79813

adding configuration from https://svn.openplans.org/svn/config_jhammel/
author k0s <k0scist@gmail.com>
date Thu, 15 Oct 2009 11:41:26 -0400
parents
children f890a12d8cf5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.bash_overrides	Thu Oct 15 11:41:26 2009 -0400
@@ -0,0 +1,109 @@
+#!/bin/bash
+
+function unlink {	
+    command unlink `echo $@ | sed 's/\/$//g'`
+}
+
+function find {
+
+    if (( ! $# ))
+    then
+	return
+    fi
+    
+    if [ -d $1 ]
+    then
+	DIR="$1"
+	shift
+    else
+	DIR="$PWD"
+    fi
+    
+    if [ "$#" == "1" ]
+    then
+	`which find` -L "$PWD" -not -path '*.svn*' -iname "$1"
+	return 0
+    fi
+
+    COMMAND="`which find` -L \"$DIR\" -not -path '*.svn*' $@"
+#echo $COMMAND # for debugging
+    `which find` -L "$DIR" -not -path '*.svn*' "$@"
+}
+
+cd() {
+    
+    ENV=""
+    # find if you're in a
+    if [ -n "${WORKING_ENV}" ]
+    then
+	ENV="${WORKING_ENV}"
+    fi
+    if [ -n "${VIRTUAL_ENV}" ]
+    then
+	ENV="${VIRTUAL_ENV}"
+    fi
+
+
+    if [ -d "$@" ]
+    then		
+	command cd "$@"
+    else
+	if [ -e "$@" ]
+	then
+	    command cd `dirname "$@"`
+	else
+	    if [[ "$@" == "^"  &&  -n "${ENV}" ]]
+	    then
+		command cd "${ENV}"
+	    else
+		command cd "$@"
+	    fi
+	fi
+    fi
+
+    # handle ENVs
+    if [ -e "bin/activate" ]
+    then
+	if [ -n "${ENV}" ]
+        then
+	    if [ "${ENV}" != "${PWD}" ]
+	    then
+		if [[ -n "`type -t deactivate`" ]]
+		then
+		    deactivate
+		fi
+	    else
+		return 
+	    fi
+	fi
+	source "bin/activate"
+    fi
+
+    ENV=""
+    # find if you're in a
+    if [ -n "${WORKING_ENV}" ]
+    then
+	ENV="${WORKING_ENV}"
+    fi
+    if [ -n "${VIRTUAL_ENV}" ]
+    then
+	ENV="${VIRTUAL_ENV}"
+    fi
+
+    if [ -n "${ENV}" ]
+    then
+	FULLPWD=$(python -c 'import os; print os.getcwd()')
+	if (( ! `expr match "${FULLPWD}" "${ENV}"` ))
+	then 
+	    if [[ -n "`type -t deactivate`" ]]
+	    then
+		deactivate
+	    fi
+	fi
+    fi
+    unset ENV
+}
+
+emacsclient() {
+    command emacsclient $@ > /dev/null &
+}