1 # Initialization: activate autoenv or report its absence
3 local d autoenv_dir install_locations
4 if ! type autoenv_init >/dev/null; then
5 # Check if activate.sh is in $PATH
6 if (( $+commands[activate.sh] )); then
7 autoenv_dir="${commands[activate.sh]:h}"
10 # Locate autoenv installation
11 if [[ -z $autoenv_dir ]]; then
15 /usr/local/opt/autoenv
16 /opt/homebrew/opt/autoenv
18 /usr/share/autoenv-git
21 for d ( $install_locations ); do
22 if [[ -e $d/activate.sh ]]; then
29 # Look for Homebrew path as a last resort
30 if [[ -z "$autoenv_dir" ]] && (( $+commands[brew] )); then
31 d=$(brew --prefix)/opt/autoenv
32 if [[ -e $d/activate.sh ]]; then
37 # Complain if autoenv is not installed
38 if [[ -z $autoenv_dir ]]; then
40 -------- AUTOENV ---------
41 Could not locate autoenv installation.
42 Please check if autoenv is correctly installed.
43 In the meantime the autoenv plugin is DISABLED.
44 --------------------------
49 source $autoenv_dir/activate.sh
52 [[ $? != 0 ]] && return $?
54 # The use_env call below is a reusable command to activate/create a new Python
55 # virtualenv, requiring only a single declarative line of code in your .env files.
56 # It only performs an action if the requested virtualenv is not the current one.
61 if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
62 if workon | grep -q "$venv"; then
65 echo -n "Create virtualenv $venv now? (Yn) "
67 if [[ "$answer" == "Y" ]]; then