annotate .bash_overrides @ 293:45b970048ae2

resurrect this ole beast
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 11 May 2013 03:24:47 -0700
parents f890a12d8cf5
children 1a177f9b51d4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
1 #!/bin/bash
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
2 # command overrides too elaborate for aliases
0
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
3
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
4 cd() {
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
5
0
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
6 ENV=""
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
7 if [ -n "${VIRTUAL_ENV}" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
8 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
9 ENV="${VIRTUAL_ENV}"
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
10 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
11
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
12
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
13 if [ -d "$@" ]
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
14 then
0
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
15 command cd "$@"
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
16 else
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
17 if [ -e "$@" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
18 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
19 command cd `dirname "$@"`
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
20 else
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
21 if [[ "$@" == "^" && -n "${ENV}" ]]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
22 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
23 command cd "${ENV}"
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
24 else
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
25 command cd "$@"
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
26 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
27 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
28 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
29
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
30 # handle ENVs
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
31 if [ -e "bin/activate" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
32 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
33 if [ -n "${ENV}" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
34 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
35 if [ "${ENV}" != "${PWD}" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
36 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
37 if [[ -n "`type -t deactivate`" ]]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
38 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
39 deactivate
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
40 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
41 else
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
42 return
0
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
43 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
44 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
45 source "bin/activate"
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
46 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
47
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
48 ENV=""
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
49 if [ -n "${VIRTUAL_ENV}" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
50 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
51 ENV="${VIRTUAL_ENV}"
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
52 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
53
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
54 if [ -n "${ENV}" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
55 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
56 FULLPWD=$(python -c 'import os; print os.getcwd()')
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
57 if (( ! `expr match "${FULLPWD}" "${ENV}"` ))
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
58 then
0
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
59 if [[ -n "`type -t deactivate`" ]]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
60 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
61 deactivate
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
62 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
63 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
64 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
65 unset ENV
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
66 }
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
67
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
68 function emacsclient() {
0
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
69 command emacsclient $@ > /dev/null &
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
70 }
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
71
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
72 function find {
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
73
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
74 if (( ! $# ))
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
75 then
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
76 return
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
77 fi
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
78
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
79 if [ -d $1 ]
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
80 then
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
81 DIR="$1"
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
82 shift
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
83 else
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
84 DIR="$PWD"
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
85 fi
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
86
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
87 if [ "$#" == "1" ]
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
88 then
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
89 `which find` -L "$PWD" -not -path '*.svn*' -iname "$1"
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
90 return 0
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
91 fi
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
92
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
93 COMMAND="`which find` -L \"$DIR\" -not -path '*.svn*' $@"
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
94 #echo $COMMAND # for debugging
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
95 `which find` -L "$DIR" -not -path '*.svn*' "$@"
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
96 }
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
97
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
98 function lsdiff {
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
99
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
100 if expr "$1" : 'http[s]\?://.*' &> /dev/null
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
101 then
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
102 curl "$1" 2> /dev/null | command lsdiff
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
103 else
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
104 lsdiff "$1"
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
105 fi
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
106
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
107 }
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
108
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
109 function unlink {
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
110 command unlink `echo $@ | sed 's/\/$//g'`
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
111 }
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
112