Mercurial > hg > config
annotate .bash_overrides @ 923:b25fbb9257ec
Breeze GTK theme
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Thu, 14 Nov 2024 09:30:28 -0800 |
parents | 753b1c2bd64c |
children |
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 |
564 | 57 FULLPWD=$(python -c 'import os; print (os.getcwd())') |
751 | 58 if (( ! `expr "${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 |
414 | 100 # make hg safer since $HOME is versioned |
412
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
101 function hg { |
413 | 102 if [[ "$(command hg root)" == "${HOME}" ]] |
412
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
103 then |
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
104 if [[ "$*" == st* ]] |
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
105 then |
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
106 command hg st -q |
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
107 return |
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
108 fi |
414 | 109 if [[ "$*" == res* ]] || [[ "$*" == pur* ]] |
412
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
110 then |
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
111 echo "Aborting \'hg $*\'; hg root is ${HOME}!" |
413 | 112 return 1 |
412
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
113 fi |
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
114 fi |
417 | 115 command hg "$@" |
412
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
116 } |
5bee5c55a7a0
args test + bash overrides hg safety
Jeff Hammel <jhammel@mozilla.com>
parents:
312
diff
changeset
|
117 |
287
f890a12d8cf5
add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
118 function lsdiff { |
305
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
302
diff
changeset
|
119 # 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
|
120 if expr "$1" : 'http[s]\?://.*' &> /dev/null |
f890a12d8cf5
add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
121 then |
302
1a177f9b51d4
follow the damn redirects
Jeff Hammel <jhammel@mozilla.com>
parents:
287
diff
changeset
|
122 curl --location "$1" 2> /dev/null | command lsdiff |
287
f890a12d8cf5
add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
123 else |
312 | 124 command lsdiff "$@" |
287
f890a12d8cf5
add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
125 fi |
f890a12d8cf5
add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
126 |
f890a12d8cf5
add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
127 } |
f890a12d8cf5
add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
128 |
544 | 129 function mv { |
130 num=$# | |
131 if (( num == 0 )) | |
132 then | |
133 command mv "$@" | |
134 return | |
135 fi | |
136 last=${!#} | |
559 | 137 if [[ "${last:(-1)}" == "/" ]] |
138 then | |
139 directory=${last} | |
140 else | |
141 directory=$(dirname ${last}) | |
142 fi | |
544 | 143 if [[ ! -e "${directory}" ]] |
144 then | |
145 mkdir -p "${directory}" | |
146 fi | |
147 command mv "$@" | |
148 return | |
149 | |
150 } | |
151 | |
287
f890a12d8cf5
add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
152 function unlink { |
f890a12d8cf5
add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
153 command unlink `echo $@ | sed 's/\/$//g'` |
f890a12d8cf5
add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
154 } |
f890a12d8cf5
add lsdiff override for urls
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
155 |