Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Oh My Zsh
Commits
58e38155
Commit
58e38155
authored
Dec 18, 2015
by
Andrew Janke
Committed by
Marc Cornellà
Mar 12, 2020
Browse files
autoenv: look in additional installation locations, redo logic
Fixes #4681 Co-authored-by:
Marc Cornellà
<
marc.cornella@live.com
>
parent
610b2529
Changes
2
Show whitespace changes
Inline
Side-by-side
plugins/autoenv/README.md
View file @
58e38155
...
@@ -7,8 +7,14 @@ To use it, add `autoenv` to the plugins array in your zshrc file:
...
@@ -7,8 +7,14 @@ To use it, add `autoenv` to the plugins array in your zshrc file:
```
zsh
```
zsh
plugins
=(
... autoenv
)
plugins
=(
... autoenv
)
```
```
## Functions
*
`use_env()`
: creates and/or activates a virtualenv. For use in
`.env`
files.
See the source code for details.
## Requirements
## Requirements
In order to make this work, you will need to have the autoenv installed.
In order to make this work, you will need to have the autoenv installed.
More info on the usage and install
:
https://github.com/inishchith/autoenv
More info on the usage and install
at
[
the project's homepage
](
https://github.com/inishchith/autoenv
)
.
plugins/autoenv/autoenv.plugin.zsh
View file @
58e38155
#
A
ctivate
s
autoenv or report
s
its
failur
e
#
Initialization: a
ctivate autoenv or report its
absenc
e
()
{
()
{
local
d autoenv_dir install_locations
if
!
type
autoenv_init
>
/dev/null
;
then
if
!
type
autoenv_init
>
/dev/null
;
then
for
d
(
~/.autoenv ~/.local/bin /usr/local/opt/autoenv /usr/local/bin
)
;
do
# Check if activate.sh is in $PATH
if
((
$+
commands[activate.sh]
))
;
then
autoenv_dir
=
"
${
commands
[activate.sh]
:h
}
"
fi
# Locate autoenv installation
if
[[
-z
$autoenv_dir
]]
;
then
install_locations
=(
~/.autoenv
~/.local/bin
/usr/local/opt/autoenv
/usr/local/bin
/usr/share/autoenv-git
~/Library/Python/bin
)
for
d
(
$install_locations
)
;
do
if
[[
-e
$d
/activate.sh
]]
;
then
if
[[
-e
$d
/activate.sh
]]
;
then
autoenv_dir
=
$d
autoenv_dir
=
$d
break
break
fi
fi
done
done
fi
# Look for Homebrew path as a last resort
if
[[
-z
"
$autoenv_dir
"
]]
&&
((
$+
commands[brew]
))
;
then
d
=
$(
brew
--prefix
)
/opt/autoenv
if
[[
-e
$d
/activate.sh
]]
;
then
autoenv_dir
=
$d
fi
fi
# Complain if autoenv is not installed
if
[[
-z
$autoenv_dir
]]
;
then
if
[[
-z
$autoenv_dir
]]
;
then
cat
<<
END
>&2
cat
<<
END
>&2
-------- AUTOENV ---------
-------- AUTOENV ---------
...
@@ -17,6 +44,7 @@ In the meantime the autoenv plugin is DISABLED.
...
@@ -17,6 +44,7 @@ In the meantime the autoenv plugin is DISABLED.
END
END
return
1
return
1
fi
fi
# Load autoenv
source
$autoenv_dir
/activate.sh
source
$autoenv_dir
/activate.sh
fi
fi
}
}
...
@@ -27,7 +55,7 @@ fi
...
@@ -27,7 +55,7 @@ fi
# It only performs an action if the requested virtualenv is not the current one.
# It only performs an action if the requested virtualenv is not the current one.
use_env
()
{
use_env
()
{
typeset
venv
local
venv
venv
=
"
$1
"
venv
=
"
$1
"
if
[[
"
${
VIRTUAL_ENV
:t
}
"
!=
"
$venv
"
]]
;
then
if
[[
"
${
VIRTUAL_ENV
:t
}
"
!=
"
$venv
"
]]
;
then
if
workon |
grep
-q
"
$venv
"
;
then
if
workon |
grep
-q
"
$venv
"
;
then
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment