Mercurial > hg > config
comparison .bashrc @ 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 | 9541511ed9d0 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f3ab51c79813 |
---|---|
1 source /etc/profile | |
2 | |
3 # Test for an interactive shell. There is no need to set anything | |
4 # past this point for scp and rcp, and it's important to refrain from | |
5 # outputting anything in those cases. | |
6 if [[ $- != *i* ]] ; then | |
7 # Shell is non-interactive. Be done now! | |
8 return | |
9 fi | |
10 | |
11 # Enable colors for ls, etc. Prefer ~/.dir_colors #64489 | |
12 if [[ -f ~/.dir_colors ]] ; then | |
13 eval $(dircolors -b ~/.dir_colors) | |
14 elif [[ -f /etc/DIR_COLORS ]] ; then | |
15 eval $(dircolors -b /etc/DIR_COLORS) | |
16 fi | |
17 | |
18 export CLICOLOR=1 | |
19 export EDITOR='emacs -nw' | |
20 | |
21 # aliases | |
22 alias ls='ls --color=auto' | |
23 alias grep='grep --colour=auto' | |
24 alias wget='wget --no-check-certificate' | |
25 alias datestamp='date +%Y%m%d%H%M%S' | |
26 alias zfilt='grep -v "eprecat" | grep -v "ERROR Zope"' | |
27 alias svnst='svn st | grep -v "^\?"' | |
28 alias awd="python -c 'import os; print os.path.realpath(\".\")'" | |
29 alias distribute='python setup.py egg_info -RDb "" sdist bdist_egg register upload' | |
30 alias random="python -c 'import sys, random; foo = sys.argv[1:]; random.shuffle(foo); print \" \".join(foo)'" | |
31 | |
32 PS1='> ' | |
33 PS2='. ' | |
34 PROMPT_COMMAND='echo -ne "\033]0;${SSH_CLIENT/*/$HOSTNAME:}${PWD/~/~}\007"' | |
35 | |
36 export PATH=~/bin:~/python:$PATH:/usr/sbin:/usr/games/bin | |
37 export PYTHONPATH=~/python:$PYTHONPATH | |
38 | |
39 cdwin() { | |
40 DIR=$(xwininfo | dictify.py xwininfo | awk '{ print $NF }' | sed 's/"//g') | |
41 DIR=${DIR/\~/$HOME} | |
42 cd $DIR | |
43 } | |
44 | |
45 eend() { | |
46 FILE=$1 | |
47 shift | |
48 emacs +`wc -l "$FILE"` $@ | |
49 } | |
50 | |
51 # nice fast find function | |
52 EXCLUDES="(\.svn)|(\.mo$)|(\.po$)|(\.pyc$)" | |
53 ff() { | |
54 | |
55 if (( $# < 2 )) | |
56 then | |
57 FILENAME='*' # default -- look in all files | |
58 else | |
59 FILENAME=$2 | |
60 fi | |
61 CMD='command find -L $PWD -iname "${FILENAME}" -print0 | xargs -r0 grep -il "$1" | egrep -v "${EXCLUDES}"' | |
62 # echo $CMD | |
63 eval $CMD | |
64 | |
65 } | |
66 | |
67 chainff() { | |
68 if (( $# < 2 )) | |
69 then | |
70 return 0 | |
71 fi | |
72 | |
73 RESULTS=`ff "$2" "$1"` | |
74 shift 2 | |
75 | |
76 for i in $RESULTS | |
77 do | |
78 for arg in $@ | |
79 do | |
80 if grep -il "$arg" "$i" &> /dev/null | |
81 then | |
82 touch /dev/null | |
83 else | |
84 i="" | |
85 break | |
86 fi | |
87 done | |
88 if [ -n "$i" ] | |
89 then | |
90 echo $i | |
91 fi | |
92 done | |
93 } | |
94 | |
95 tmpfile() { | |
96 | |
97 | |
98 if [ "$#" == "0" ] | |
99 then | |
100 args="." | |
101 else | |
102 args=$@ | |
103 fi | |
104 | |
105 for i in $args | |
106 do | |
107 NEWNAME=${i}.$RANDOM | |
108 | |
109 while [ -e $NEWNAME ] | |
110 do | |
111 NEWNAME=${NEWNAME}.tmp | |
112 done | |
113 echo "$NEWNAME" | |
114 done | |
115 } | |
116 | |
117 edpe() { | |
118 | |
119 # edit and pipe the buffer to stdout | |
120 FILE=`tmpfile` | |
121 $EDITOR $FILE | |
122 cat $FILE | |
123 rm $FILE | |
124 | |
125 } | |
126 | |
127 swap() { | |
128 if [ "$#" != "2" ] | |
129 then | |
130 echo "Usage: $FUNCNAME <first_arg> <second_arg>" | |
131 return | |
132 fi | |
133 for i in "$1" "$2" | |
134 do | |
135 if [ ! -w "$i" ] | |
136 then | |
137 echo "$FUNCNAME: Can't move $i" | |
138 return 1 | |
139 fi | |
140 done | |
141 | |
142 NEWNAME=`basename $1`.$RANDOM | |
143 | |
144 while [ -e $NEWNAME ] | |
145 do | |
146 NEWNAME=${NEWNAME}.tmp | |
147 echo "$NEWNAME" | |
148 done | |
149 | |
150 mv `basename $1` $NEWNAME | |
151 mv `basename $2` `basename $1` | |
152 mv $NEWNAME `basename $2` | |
153 } | |
154 | |
155 isrunning() { | |
156 for i in "$@" | |
157 do | |
158 ps axwww | grep "$i" | grep -v 'grep' | |
159 done | sort | uniq | |
160 | |
161 } | |
162 | |
163 killbyname() { | |
164 kill `isrunning "$@" | awk '{ print $1 }' | onelineit.py` | |
165 } | |
166 | |
167 ztest() { | |
168 | |
169 ZCTL=`find $PWD -name 'zopectl'` | |
170 if [ ! -x "$ZCTL" ] | |
171 then | |
172 echo 'zopectl not found' | |
173 return 1 | |
174 fi | |
175 | |
176 if [ "$#" == "1" ] | |
177 then | |
178 FLAG="False" | |
179 for i in '-h' '--help' | |
180 do | |
181 if [ "$i" == "$1" ] | |
182 then | |
183 FLAG="True" | |
184 break | |
185 fi | |
186 if [ "$FLAG" == "False" ] | |
187 then | |
188 ${ZCTL} test -s Products.$1 2>&1 | zfilt | |
189 echo "i'm done!" | |
190 return 0 | |
191 fi | |
192 done | |
193 | |
194 fi | |
195 | |
196 return 0 | |
197 | |
198 ${ZCTL} test $@ 2>&1 | zfilt | |
199 | |
200 } | |
201 | |
202 tf() { | |
203 if [[ $@ ]] | |
204 then | |
205 echo "true" | |
206 else | |
207 echo "false" | |
208 fi | |
209 } | |
210 | |
211 # full name | |
212 fn() { | |
213 python -c "import os; print os.path.realpath('$*')" | |
214 } | |
215 | |
216 # which view | |
217 whview() { | |
218 less `which $@` | |
219 } | |
220 | |
221 #which emacs | |
222 whemacs() { | |
223 emacs -nw `which $@` | |
224 } | |
225 | |
226 pyfile() { | |
227 python -c "import $1; print $1.__file__" | |
228 } | |
229 | |
230 function colors() { | |
231 | |
232 CLR_WHITE="\033[0;37m" | |
233 CLR_WHITEBOLD="\033[1;37m" | |
234 CLR_BLACK="\033[0;30m" | |
235 CLR_GRAY="\033[1;30m" | |
236 CLR_BLUE="\033[1;34m" | |
237 CLR_BLUEBOLD="\033[0;34m" | |
238 CLR_GREEN="\033[0;32m" | |
239 CLR_GREENBOLD="\033[1;32m" | |
240 CLR_CYAN="\033[0;36m" | |
241 CLR_CYANBOLD="\033[1;36m" | |
242 CLR_RED="\033[0;31m" | |
243 CLR_REDBOLD="\033[1;31m" | |
244 CLR_PURPLE="\033[0;35m" | |
245 CLR_PURPLEBOLD="\033[1;35m" | |
246 CLR_YELLOW="\033[0;33m" | |
247 CLR_YELLOWBOLD="\033[1;33m" | |
248 CLR_NOTHING="\033[0m" | |
249 } | |
250 | |
251 colors | |
252 | |
253 # contextual fastfind | |
254 cff () { | |
255 | |
256 if (( $# < 2 )); then | |
257 local FILENAME='*' # default -- look in all files | |
258 else | |
259 local FILENAME=$2 | |
260 fi | |
261 | |
262 for i in `ff "$1" "$FILENAME"`; do | |
263 echo -e "$CLR_GREEN--->>> ""$CLR_YELLOWBOLD""$i""$CLR_NOTHING" : | |
264 grep --color=auto -i -n -C 3 "$1" $i | |
265 done | |
266 | |
267 } | |
268 | |
269 svndance(){ | |
270 if (( $# )) | |
271 then | |
272 svn import $1 | |
273 cd .. | |
274 rm -rf $OLDPWD | |
275 svn co $1 $OLDPWD | |
276 cd $OLDPWD | |
277 else | |
278 return 1 | |
279 fi | |
280 } | |
281 | |
282 ### include overrides for commands | |
283 source ~/.bash_overrides |