Skip to content

Commit a139f21

Browse files
committed
Add a couple of quick-navigation helper functions
1 parent a98d925 commit a139f21

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

README

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ Path Management
105105

106106
The function ``add2virtualenv`` adds the specified directories to the Python path for the active virtualenv. The directory names passed as argument are added to a path file named ``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages directory. If this file does not exist, it will be created first.
107107

108+
==================================
109+
Quickly Navigating to a virtualenv
110+
==================================
111+
112+
The functions ``cdsitepackages`` and ``cdvirtualenv`` provide quick shortcuts to quickly ``cd`` into the ``site-packages`` directory of the currently-active virtualenv, and to the root of the currently-active virtualenv, respectively.
113+
108114
==========
109115
References
110116
==========

virtualenvwrapper_bashrc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,28 @@ function add2virtualenv () {
215215
done
216216
return 0
217217
}
218+
219+
#
220+
# cdsitepackages
221+
#
222+
# Does a ``cd`` to the site-packages directory of the currently-active
223+
# virtualenv.
224+
#
225+
226+
function cdsitepackages () {
227+
verify_active_environment || return 1
228+
pyvers="`python -c 'import sys; print sys.version[:3]'`"
229+
site_packages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages"
230+
cd $site_packages
231+
}
232+
233+
#
234+
# cdvirtualenv
235+
#
236+
# Does a ``cd`` to the root of the currently-active virtualenv.
237+
#
238+
239+
function cdvirtualenv () {
240+
verify_active_environment || return 1
241+
cd $VIRTUAL_ENV
242+
}

0 commit comments

Comments
 (0)