autoenv 打印 "will run" /path/to/.env 每次我 cd
autoenv printing "will run" /path/to/.env everytime I cd
我的具体问题不是每次更改到子文件夹时都会执行 source /venv/bin/activate
。问题是每次我这样做都会打印 "will run" /path/to/.env
我在 0.2.0 版本中通过自制软件安装了 autoenv。这是我的 .env
文件:
if [ -z "$VIRTUAL_ENV" ]; then
CUR_DIR=$(pwd)
# search for the next .env
while [[ "$PWD" != "/" && "$PWD" != "$home" ]]; do
env_file="$PWD/.env"
if [[ -f "$env_file" ]]; then
BASE_DIR=$(dirname $env_file)
break
fi
builtin cd ..
done
if [ ! -z "$BASE_DIR" ]; then
echo "Activating that virtualenv"
source ${BASE_DIR}/venv/bin/activate
fi
cd $CUR_DIR
fi
终端中的输出类似于:
MacBook-Pro:~ llamasramirez$ cd Desktop/oficios/
Will run /Users/llamas/Desktop/oficios/.env
Activating that virtualenv
Will run /Users/llamas/Desktop/oficios/.env
(venv) MacBook-Pro:oficios llamasramirez$ cd django_sites/polls/
Will run /Users/llamas/Desktop/oficios/.env
(venv) MacBook-Pro:polls llamasramirez$
原来问题不在 .env
文件中。问题出在 activate.sh
文件中。
打开 autoenv_init
函数有一个 for 循环,它会生成烦人的 echo 指令:
for _file in ${_orderedfiles}; do
echo "Will run ${_file}"
autoenv_check_authz_and_run "${_file}"
done
当我对此发表评论时,回显不会再次弹出。
我的具体问题不是每次更改到子文件夹时都会执行 source /venv/bin/activate
。问题是每次我这样做都会打印 "will run" /path/to/.env
我在 0.2.0 版本中通过自制软件安装了 autoenv。这是我的 .env
文件:
if [ -z "$VIRTUAL_ENV" ]; then
CUR_DIR=$(pwd)
# search for the next .env
while [[ "$PWD" != "/" && "$PWD" != "$home" ]]; do
env_file="$PWD/.env"
if [[ -f "$env_file" ]]; then
BASE_DIR=$(dirname $env_file)
break
fi
builtin cd ..
done
if [ ! -z "$BASE_DIR" ]; then
echo "Activating that virtualenv"
source ${BASE_DIR}/venv/bin/activate
fi
cd $CUR_DIR
fi
终端中的输出类似于:
MacBook-Pro:~ llamasramirez$ cd Desktop/oficios/
Will run /Users/llamas/Desktop/oficios/.env
Activating that virtualenv
Will run /Users/llamas/Desktop/oficios/.env
(venv) MacBook-Pro:oficios llamasramirez$ cd django_sites/polls/
Will run /Users/llamas/Desktop/oficios/.env
(venv) MacBook-Pro:polls llamasramirez$
原来问题不在 .env
文件中。问题出在 activate.sh
文件中。
打开 autoenv_init
函数有一个 for 循环,它会生成烦人的 echo 指令:
for _file in ${_orderedfiles}; do
echo "Will run ${_file}"
autoenv_check_authz_and_run "${_file}"
done
当我对此发表评论时,回显不会再次弹出。