comparison .bash_overrides @ 287:f890a12d8cf5

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