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
1cc32be5
Unverified
Commit
1cc32be5
authored
Sep 20, 2023
by
ajatkj
Committed by
GitHub
Sep 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(poetry-env): create plugin (#11069)
parent
350427de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
README.md
plugins/poetry-env/README.md
+10
-0
poetry-env.plugin.zsh
plugins/poetry-env/poetry-env.plugin.zsh
+27
-0
No files found.
plugins/poetry-env/README.md
0 → 100644
View file @
1cc32be5
# Poetry Environment Plugin
This plugin automatically changes poetry environment when you cd into or out of the project directory.
Note: Script looks for pyproject.toml file to determine poetry if its a poetry environment
To use it, add
`poetry-env`
to the plugins array in your zshrc file:
```
zsh
plugins
=(
... poetry-env
)
```
plugins/poetry-env/poetry-env.plugin.zsh
0 → 100644
View file @
1cc32be5
# Automatic poetry environment activation/deactivation
_togglePoetryShell
()
{
# deactivate environment if pyproject.toml doesn't exist and not in a subdir
if
[[
!
-f
"
$PWD
/pyproject.toml"
]]
;
then
if
[[
"
$poetry_active
"
==
1
]]
;
then
if
[[
"
$PWD
"
!=
"
$poetry_dir
"
*
]]
;
then
export
poetry_active
=
0
deactivate
return
fi
fi
fi
# activate the environment if pyproject.toml exists
if
[[
"
$poetry_active
"
!=
1
]]
;
then
if
[[
-f
"
$PWD
/pyproject.toml"
]]
;
then
if
grep
-q
'tool.poetry'
"
$PWD
/pyproject.toml"
;
then
export
poetry_active
=
1
export
poetry_dir
=
"
$PWD
"
source
"
$(
poetry
env
info
--path
)
/bin/activate"
fi
fi
fi
}
autoload
-U
add-zsh-hook
add-zsh-hook chpwd _togglePoetryShell
_togglePoetryShell
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