annotate .bash_overrides @ 338:5438630e118c

second commit
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 19 Jun 2013 10:46:48 -0700
parents 597455a28c49
children 5bee5c55a7a0
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
305
fac01a1bcedf add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents: 302
diff changeset
2
fac01a1bcedf add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents: 302
diff changeset
3 ### 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
4
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
5 cd() {
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
6
0
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
7 ENV=""
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
8 if [ -n "${VIRTUAL_ENV}" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
9 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
10 ENV="${VIRTUAL_ENV}"
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
11 fi
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
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
14 if [ -d "$@" ]
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
15 then
0
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
16 command cd "$@"
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
17 else
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
18 if [ -e "$@" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
19 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
20 command cd `dirname "$@"`
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
21 else
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
22 if [[ "$@" == "^" && -n "${ENV}" ]]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
23 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
24 command cd "${ENV}"
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
25 else
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
26 command cd "$@"
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 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
30
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
31 # handle ENVs
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
32 if [ -e "bin/activate" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
33 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
34 if [ -n "${ENV}" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
35 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
36 if [ "${ENV}" != "${PWD}" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
37 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
38 if [[ -n "`type -t deactivate`" ]]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
39 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
40 deactivate
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
41 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
42 else
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
43 return
0
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 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
46 source "bin/activate"
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
47 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
48
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
49 ENV=""
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
50 if [ -n "${VIRTUAL_ENV}" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
51 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
52 ENV="${VIRTUAL_ENV}"
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
53 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
54
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
55 if [ -n "${ENV}" ]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
56 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
57 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
58 if (( ! `expr match "${FULLPWD}" "${ENV}"` ))
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
59 then
0
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
60 if [[ -n "`type -t deactivate`" ]]
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
61 then
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
62 deactivate
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 fi
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
66 unset ENV
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
67 }
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
68
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
69 function emacsclient() {
0
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
70 command emacsclient $@ > /dev/null &
f3ab51c79813 adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff changeset
71 }
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
72
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
73 function find {
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
74
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
75 if (( ! $# ))
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
76 then
305
fac01a1bcedf add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents: 302
diff changeset
77 command find
fac01a1bcedf add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents: 302
diff changeset
78 return
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
79 fi
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
80
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
81 if [ -d $1 ]
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
82 then
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
83 DIR="$1"
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
84 shift
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
85 else
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
86 DIR="$PWD"
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
87 fi
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
88
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
89 if [ "$#" == "1" ]
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
90 then
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
91 `which find` -L "$PWD" -not -path '*.svn*' -iname "$1"
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
92 return 0
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
93 fi
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
94
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
95 COMMAND="`which find` -L \"$DIR\" -not -path '*.svn*' $@"
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
96 #echo $COMMAND # for debugging
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
97 `which find` -L "$DIR" -not -path '*.svn*' "$@"
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
98 }
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 function lsdiff {
305
fac01a1bcedf add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents: 302
diff changeset
101 # TODO: extract this general pattern as a bash "decorator"
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
102 if expr "$1" : 'http[s]\?://.*' &> /dev/null
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
103 then
302
1a177f9b51d4 follow the damn redirects
Jeff Hammel <jhammel@mozilla.com>
parents: 287
diff changeset
104 curl --location "$1" 2> /dev/null | command lsdiff
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
105 else
312
597455a28c49 utilize command
Jeff Hammel <jhammel@mozilla.com>
parents: 305
diff changeset
106 command lsdiff "$@"
287
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
107 fi
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 }
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
110
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
111 function unlink {
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
112 command unlink `echo $@ | sed 's/\/$//g'`
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
113 }
f890a12d8cf5 add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
114