Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
58e38155
Commit
58e38155
authored
Dec 18, 2015
by
Andrew Janke
Committed by
Marc Cornellà
Mar 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autoenv: look in additional installation locations, redo logic
Fixes #4681 Co-authored-by:
Marc Cornellà
<
marc.cornella@live.com
>
parent
610b2529
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
17 deletions
+51
-17
README.md
plugins/autoenv/README.md
+7
-1
autoenv.plugin.zsh
plugins/autoenv/autoenv.plugin.zsh
+44
-16
No files found.
plugins/autoenv/README.md
View file @
58e38155
...
...
@@ -7,8 +7,14 @@ To use it, add `autoenv` to the plugins array in your zshrc file:
```
zsh
plugins
=(
... autoenv
)
```
## Functions
*
`use_env()`
: creates and/or activates a virtualenv. For use in
`.env`
files.
See the source code for details.
## Requirements
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
#
Activates autoenv or reports its failur
e
#
Initialization: activate autoenv or report its absenc
e
()
{
local
d autoenv_dir install_locations
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
autoenv_dir
=
$d
break
fi
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
break
fi
done
fi
# Complain if autoenv is not installed
if
[[
-z
$autoenv_dir
]]
;
then
cat
<<
END
>&2
-------- AUTOENV ---------
...
...
@@ -17,6 +44,7 @@ In the meantime the autoenv plugin is DISABLED.
END
return
1
fi
# Load autoenv
source
$autoenv_dir
/activate.sh
fi
}
...
...
@@ -27,17 +55,17 @@ fi
# It only performs an action if the requested virtualenv is not the current one.
use_env
()
{
typeset
venv
venv
=
"
$1
"
if
[[
"
${
VIRTUAL_ENV
:t
}
"
!=
"
$venv
"
]]
;
then
if
workon |
grep
-q
"
$venv
"
;
then
workon
"
$venv
"
else
echo
-n
"Create virtualenv
$venv
now? (Yn) "
read
answer
if
[[
"
$answer
"
==
"Y"
]]
;
then
mkvirtualenv
"
$venv
"
fi
fi
local
venv
venv
=
"
$1
"
if
[[
"
${
VIRTUAL_ENV
:t
}
"
!=
"
$venv
"
]]
;
then
if
workon |
grep
-q
"
$venv
"
;
then
workon
"
$venv
"
else
echo
-n
"Create virtualenv
$venv
now? (Yn) "
read
answer
if
[[
"
$answer
"
==
"Y"
]]
;
then
mkvirtualenv
"
$venv
"
fi
fi
fi
}
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