dotfiles

Author: Kyle Fuller <inbox@kylefuller.co.uk> 2011-06-26 04:31:47 +0100 +0100
Committer: Kyle Fuller <inbox@kylefuller.co.uk> 2011-06-26 04:31:47 +0100 +0100
Commit: fcecea018ec00778797bf98514f987c2c0582c2f
Parent: bd10a35d9a3f0e8f4ab5b469d274ffea3356661b


Add pycd function, this will allow you to cd into a directory from its python module
diff --git a/rc b/rc
index f761721e85572efb4925a82798273ac6d853eee8..90d9e83824d79eddebfcdf2bcffe7ecba3588d11 100644
--- a/rc
+++ b/rc
@@ -14,6 +14,12 @@ elif command_exists vi ; then
   export EDITOR=vi
 fi
 
+pycd () {
+  # cd into a python module directory
+  # django.contrib.admin > $PYTHONPATH/django/contrib/admin
+  cd $(python -c "import $1; print $1.__file__" | xargs dirname)
+}
+
 alias v=$EDITOR
 alias gdiff='git diff | $EDITOR -R -'
 alias grev='git rev'