# simple shortcuts export MY_DEV_PATH=~/development export MY_EDITOR=mate ed () { if [ "$#" -lt 1 ]; then echo "Usage: ed \"editor args + directory or filename\"" return; fi $MY_EDITOR $*; } bashrc () { ed ~/.bashrc; } reload () { source ~/.bashrc; source ~/.profile; echo '.bashrc and .profile reloaded!'; } #python py () { python $*; } ipy () { ipython $*; } #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 "djd args - changes directories to django development and allows for path to app or site."; echo " >> e.g. djd app/django_foo djd sites/django_bar"; echo "djrs calls runserver in the current site/project and passes on optional arguments"; echo "djsh - atempts to run django shell_plus but defaults to shell if django-extentions are not installed!" echo ""; echo "=== DJANGO SITES ========================"; echo "djs - changes directories to django sites development and allows for direct access site"; echo " >> e.g. djs django_site"; echo "djes - same as above but launches the folder in you favorite editor."; echo ""; echo "=== DJANGO APPS ========================"; echo "dja - changes directories to django app development and allows for direct access to an app"; echo " >> e.g. dja django_app"; echo "djea - same as above but launches the folder in you favorite editor."; echo "djmka - creates a reusealble director with django-app-name and default files also initilizes the folder as git repo"; echo " >> e.g. djmka foo-bar"; echo "djea - same as above but launches the folder in you favorite editor."; } #django dev djd () { cd $DEV_DJANGO/$*;} #django runserver djrs () { ./manage.py runserver $*; } #django shellplus requires django_extensions djsh () { ./manage.py shell_plus || echo "Using Default Django shell instead!" && djshb; } djshb () { ./manage.py shell; } djsdb () { ./manage.py syncdb; } djre () { if [ "$#" -lt 1 ]; then echo "Usage: djre \"django app name\"" return; fi ./manage.py reset $1; } # django app functions dja () { cd $DEV_DJANGO_APPS/$*; } djea () { if [ "$#" -lt 1 ]; then echo "Usage: djea \"django app name\"" return; fi ed $DEV_DJANGO_APPS/$1; } djmka () { if [ "$#" -lt 1 ]; then echo "Usage: djmka \"django app name\"" return; fi # define path new_app_path=$DEV_DJANGO_APPS/"django-"$1; # make default folders mkdir -p $new_app_path"/examples" $new_app_path"/docs" $new_app_path"/tests"; cd $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 plink $1 $1; } djs () { cd $DEV_DJANGO_SITES/$*; } djes () { if [ "$#" -lt 1 ]; then echo "Usage: djse \"django site name\"" return; fi cd $DEV_DJANGO_SITES/$1; ed .; } djmks () { if [ "$#" -lt 1 ]; then echo "Usage: da \"django project name\"" return; fi pushd $DEV_DJANGO_SITES; django-admin.py startproject $1; popd; }