-
Notifications
You must be signed in to change notification settings - Fork 0
/
.envrc
44 lines (38 loc) · 1.04 KB
/
.envrc
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
#!/usr/bin/env bash
#- ensure virtual env
PYTHON=python3
if [ -r requirements.txt ]; then
if [ ! -d ".env" ] ; then
virtualenv .env -p $PYTHON
.env/bin/pip install --upgrade pip
.env/bin/pip install -r requirements.txt
echo "direnv: created virtualenv in $PWD/.env with $($PYTHON -V)"
fi
fi
if [ -r .env/bin/activate ]; then
. .env/bin/activate
echo "direnv: activated $($PYTHON -V) virtualenv in $PWD/.env"
fi
unset PYTHON
#- add ./bin if it exists
if [ -d "./bin" ] ; then
PATH="$PATH:$PWD/bin"
fi
#- disable warnings about direnv not able to set PS1
# see: https://github.com/direnv/direnv/wiki/PS1
unset PS1
#- do a stable filtering to have each PATH only once in PATH
_PATH="$PATH"
PATH=
while [ -n "$_PATH" ]; do
p="${_PATH%%:*}"; _PATH="${_PATH#$p}"; _PATH="${_PATH#:}"
[ -d "$p" ] || continue
case "$PATH" in
$p | $p:* | *:$p | *:$p:* ) ;;
"" ) PATH="$p" ;;
* ) PATH="$PATH:$p" ;;
esac
done
unset p _PATH
export PATH
# vim: sw=2 ts=2 et