Permalink
Browse files

remove python dependency, speedup

  • Loading branch information...
mpapis committed Feb 13, 2012
1 parent 5390271 commit dafcd74218ed7728173a60bb28d3d0e9df225a04
Showing with 15 additions and 44 deletions.
  1. +15 −12 activate.sh
  2. +0 −32 detect_env.py
View
@@ -1,25 +1,28 @@
#!/usr/bin/env bash
-AUTOENV_DIR="$(dirname $0)"
-
-autoenv-init()
+autoenv_init()
{
- typeset IFS cmd
- typeset -a cmds
- IFS=$'\n'
- cmds=( $( "${AUTOENV_DIR}/detect_env.py" ) )
+ typeset target home _file
+ target=$1
+ home="$(dirname $HOME)"
- for cmd in ${cmds}
- do
- eval $cmd
- done
+ (
+ while [[ "$PWD" != "/" && "$PWD" != "$home" ]]
+ do
+ _file="$PWD/.env"
+ if [[ -e "${_file}" ]]
+ then source "${_file}"
+ fi
+ builtin cd ..
+ done
+ )
}
cd()
{
if builtin cd "$@"
then
- autoenv-init
+ autoenv_init
return 0
else
return $?
View
@@ -1,32 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import os
-
-
-
-def find_above(*names):
- """Attempt to locate a .env file by searching parent dirs."""
-
- path = '.'
-
- found = []
-
- while os.path.split(os.path.abspath(path))[1]:
- for name in names:
- joined = os.path.join(path, name)
- if os.path.exists(joined):
- found.insert(0, os.path.abspath(joined))
- path = os.path.join('..', path)
-
- return found
-
-
-if __name__ == '__main__':
-
- # Is there an .env file?
- envfiles = find_above('.env')
-
- for envfile in envfiles:
- # Do it live!
- print 'source %s' % envfile

0 comments on commit dafcd74

Please sign in to comment.