-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_bashrc
More file actions
294 lines (231 loc) · 6.9 KB
/
_bashrc
File metadata and controls
294 lines (231 loc) · 6.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# simple shortcuts
export MY_DEV_PATH=~/development
export MY_EDITOR=mate
edbp () {
ed $MY_DEV_PATH/bash-profile;
}
reload () {
# Forces a reload of both the .bashrc and .profile files in the current bash session
source ~/.bashrc;
source ~/.profile;
echo '.bashrc and .profile reloaded!';
}
ed () {
if [ "$#" -lt 1 ]; then
echo "Usage: ed \"editor args + directory or filename\""
return;
fi
$MY_EDITOR $*;
}
#-----------------------------------------------------> RAILS DEV
export DEV_RAILS=$MY_DEV_PATH/rails;
cdr (){
cd $DEV_RAILS/$1;
}
# ls rails apps or give path in the rails directory
lsr (){
ls -l $DEV_RAILS/$1;
}
# Rails run server
rss (){
if [ "$#" -lt 0 ]; then
# just run script/server on local directory
./script/server
else
cd $DEV_RAILS/$1
./script/server
fi
}
edr(){
if [ "$#" -lt 1 ]; then
echo "Usage: edr rails-app";
echo "This launches the rails app supplied in your favorite editor."
return;
fi
cd $DEV_RAILS/$1
ed .
}
#-----------------------------------------------------> FLASH DEV
export DEV_FLASH=$MY_DEV_PATH/flash;
cdfl (){
cd $DEV_FLASH/$1;
}
edfl (){
if [ "$#" -lt 1 ]; then
echo "Usage: edfl \"flash app name\""
return;
fi
if [ -d $DEV_FLASH/$1 ]; then
open -ga "Adobe Flash CS4" $DEV_FLASH/$1/$1".fla";
ed $DEV_FLASH/$1;
else
echo $1 "does not exist in " $DEV_FLASH;
return;
fi
}
lsfl () {
ls -l $DEV_FLASH;
}
#-----------------------------------------------------> PYTHON Functions and Overrides
export IPYTHON_PATH=/usr/local/bin/ipython;
export LOCAL_PYTHON_PATH=~/python;
export LOCAL_PYTHON_SRC_PATH=$LOCAL_PYTHON_PATH/src;
export LOCAL_PYTHON_SITE_PACKAGES=$LOCAL_PYTHON_PATH/site-packages;
py () {
if command -v ipython >/dev/null; then
ipython $*;
else
echo "ipython is not installed using default python shell";
ppy;
fi
}
ppy () { python $*; }
#override ipython for faster launch & exits
ipython () {
$IPYTHON_PATH -noconfirm -nobanner $*;
}
cdpys () {
cd $LOCAL_PYTHON_SRC_PATH;
}
lslsp () {
ls -l $LOCAL_PYTHON_SITE_PACKAGES;
}
#-----------------------------------------------------> django Environment Variables
export DJANGO_APP_PREFIX="django-";
export DEV_DJANGO=$MY_DEV_PATH/django;
export DEV_DJANGO_APPS=$DEV_DJANGO/apps;
export DEV_DJANGO_SITES=$DEV_DJANGO/sites;
dj () {
# list all django commands here incase i forget them :)
echo "=== DJANGO COMMANDS ========================";
echo ""
echo "=== DJANGO SITES ========================";
echo ""
echo "=== DJANGO APPS ========================";
}
#django dev
cddj () { cd $DEV_DJANGO/$*;}
#django runserver
drs () { ./manage.py runserver $*; }
#django shellplus requires django_extensions
dsh () {
./manage.py shell_plus || (echo "Using Default Django shell instead!" && dshb);
}
dshb () {
./manage.py shell;
}
dsdb () { ./manage.py syncdb; }
dre () {
if [ "$#" -lt 1 ]; then
echo "Usage: djre \"django app name\""
return;
fi
./manage.py reset $1;
}
# django app functions
cdda () { cd $DEV_DJANGO_APPS/$*; }
lsda () { ls $* $DEV_DJANGO_APPS; }
edda () {
if [ "$#" -lt 1 ]; then
echo "Usage: edda django-app app";
echo "This launches each django app supplied as arguments in your favorite editor."
return;
fi
for a in $*; do
if [ -d $DEV_DJANGO_APPS/$DJANGO_APP_PREFIX$a ]; then
ed $DEV_DJANGO_APPS/$DJANGO_APP_PREFIX$a;
elif [ -d $DEV_DJANGO_APPS/$a ]; then
# old not migrated apps
# TODO remove once all apps have been ported
ed $DEV_DJANGO_APPS/$a;
else
echo "neither '"$DJANGO_APP_PREFIX$a "' or '" $a "' exist in " $DEV_DJANGO_APPS;
fi
done
}
mkda () {
if [ "$#" -lt 1 ]; then
echo "Usage: djmka \"django app name\""
return;
fi
# define path
new_app_path=$DEV_DJANGO_APPS/$DJANGO_APP_PREFIX$1;
if [ -d $new_app_path ]; then
echo $DJANGO_APP_PREFIX$1 " already exists";
fi
# TODO add python import test against existing apps on pythonpath
# make default folders
mkdir -p $new_app_path"/examples" $new_app_path"/docs" $new_app_path"/tests";
pushd $new_app_path;
# create default files
touch AUTHORS && echo "django-"$1" == TODO" > AUTHORS;
touch README && echo "django-"$1" == TODO" > README;
touch INSTALL && echo "django-"$1" == TODO" > INSTALL;
touch setup.py && echo "django-"$1" == TODO" > setup.py;
touch LICENSE && echo "django-"$1" == TODO" > LICENSE;
# create app
django-admin.py startapp $1;
# setup initial repo
git init -q && git add . && git commit -q -m "Initial Commit";
# add app to python path requires pylink/plink
pylink $1 $1;
popd;
}
rmda () {
if [ "$#" -lt 1 ]; then
echo "Usage: rmda \"django app name\" e.g. rmda people";
echo -n "This will remove '"$DJANGO_APP_PREFIX"people' from the django app folder";
echo " and the symlink from site-packages.";
return;
fi
# check to see if app exists with or without django-prefix
if [ -d $DEV_DJANGO_APPS/$DJANGO_APP_PREFIX$1 ]; then
apppath=$DEV_DJANGO_APPS/$DJANGO_APP_PREFIX$1;
elif [ -d $DEV_DJANGO_APPS/$1 ]; then
# old not migrated apps
# TODO remove once all apps have been ported
apppath=$DEV_DJANGO_APPS/$1;
else
echo "neither '"$DJANGO_APP_PREFIX$1 "' or '" $1 "' exist in " $DEV_DJANGO_APPS;
return;
fi
# ask for confirmation
echo "Are you sure you wish to delete django app: ";
echo ">> $apppath";
echo -n "Yes/No? ";
read answer;
answer="`echo $answer|tr '[:upper:]' '[:lower:]'`";
if [ "$answer" = "yes" ] || [ "$answer" = "y" ]; then
# unlink from python path
pyunlink $1;
# recursively delete app from django apps folder
rm -rfv $apppath;
echo "Django App '$apppath' successfully removed"
return;
elif [ "$answer" = "no" ] || [ "$answer" = "n" ]; then
echo "Remove django App $apppath stopped";
return;
else
echo "Nothing happend Incorrect answer";
fi
}
cdds () { cd $DEV_DJANGO_SITES/$*; }
lsds () { ls $* $DEV_DJANGO_SITES; }
edds () {
if [ "$#" -lt 1 ]; then
echo "Usage: edds \"django site name\" e.g. edds newspaper.com"
echo ">> This changes to the selected folder and launches it in your favorite editor 'Textmate'"
return;
fi
cd $DEV_DJANGO_SITES/$1;
ed .;
}
mkds () {
if [ "$#" -lt 1 ]; then
echo "Usage: mkds \"django project name\""
return;
fi
pushd $DEV_DJANGO_SITES;
django-admin.py startproject $1;
popd;
}