-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaenv.sh
56 lines (45 loc) · 948 Bytes
/
aenv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
if [ -z "$ENVS_DIR" ]; then
ENVS_DIR=~/.envs
fi
aenv_run() {
defIFS=$IFS
activate=bin/activate
envDir=.env
found=false
while IFS=: read envName projectRoot local
do
if [[ "$PWD" = "$projectRoot"* ]]; then
if [[ -n $local ]]; then
actFile=$projectRoot/$envDir/$activate
if [[ -e $actFile ]]; then
found=true
source $actFile
else
echo "Couldn't find $actFile"
fi
else
found=true
source "$ENVS_DIR/$envName/$activate"
fi
fi
done < ~/.aenv/aenv.conf
if ! $found && [[ -n "$VIRTUAL_ENV" ]]; then
deactivate
fi
IFS=$defIFS
}
aenv_cd()
{
if builtin cd "$@"
then
aenv_run
return 0
else
return $?
fi
}
cd() {
aenv_cd "$@"
}
cd .