+if has("python")
+python << END_OF_PYTHON
+import sys, os
+
+virtualenv_dir = os.environ.get('VIRTUAL_ENV')
+if virtualenv_dir:
+ sys.path.insert(0, virtualenv_dir)
+ activate_this = os.path.join(virtualenv_dir, 'bin', 'activate_this.py')
+ execfile(activate_this, dict(__file__=activate_this))
+END_OF_PYTHON
+endif
+
+
+" From Tip 212:
+" http://vim.wikia.com/wiki/Setting_file_attributes_without_reloading_a_buffer
+
+if executable('chmod')
+ function! SetExecutableBit(x)
+ checktime
+ let fx = executable(expand("%:p"))
+ execute "au FileChangedShell <buffer> call _BufChangedCB()"
+ if a:x && !fx
+ !chmod a+x %
+ elseif !a:x && fx
+ !chmod a-x %
+ endif
+ if v:shell_error
+ echoerr 'Error running chmod: ' . v:shell_error
+ endif
+ checktime
+ endfunction
+ function! _BufChangedCB()
+ execute "au! FileChangedShell <buffer>"
+ endfunction
+ command! ToggleXbit if executable(expand("%:p")) | call SetExecutableBit(0) | else | call SetExecutableBit(1) | endif
+endif
+
+