mirror of
https://github.com/kennethreitz-archive/dotfiles.git
synced 2026-06-05 23:40:16 +00:00
add AWESOME workscript for auto-enabling virtualenved projects with a .workon file
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
export WORKON_HOME=$HOME/.virtualenvs
|
||||
source /usr/local/Cellar/python/2.7.1/Frameworks/Python.framework/Versions/2.7/bin//virtualenvwrapper.sh
|
||||
source /usr/local/share/python//virtualenvwrapper.sh
|
||||
export VIRTUALENV_USE_DISTRIBUTE="1"
|
||||
|
||||
|
||||
function cd(){
|
||||
builtin cd "$@"
|
||||
$(/Users/kreitz/.oh-my-zsh/tools/workon.py)
|
||||
}
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
def find_above(*names):
|
||||
"""Attempt to locate a .workon file by searching parent dirs."""
|
||||
|
||||
path = '.'
|
||||
|
||||
while os.path.split(os.path.abspath(path))[1]:
|
||||
for name in names:
|
||||
joined = os.path.join(path, name)
|
||||
if os.path.exists(joined):
|
||||
return os.path.abspath(joined)
|
||||
path = os.path.join('..', path)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
wo_file = find_above('.workon')
|
||||
if wo_file and not 'VIRTUAL_ENV' in os.environ.keys():
|
||||
with open(wo_file) as f:
|
||||
print('source {0}/bin/activate'.format(f.read()))
|
||||
|
||||
elif not wo_file and 'VIRTUAL_ENV' in os.environ.keys():
|
||||
print('deactivate')
|
||||
Reference in New Issue
Block a user