diff --git a/docs/cli.md b/docs/cli.md index 67020f2c33c..19d6767bcc0 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -655,29 +655,6 @@ poetry run my-script Note that this command has no option. -## shell - -The shell command spawns a shell within the project's virtual environment. - -By default, the current active shell is detected and used. Failing that, -the shell defined via the environment variable `SHELL` (on *nix) or -`COMSPEC` (on Windows) is used. - -If a virtual environment does not exist, it will be created. - -```bash -poetry shell -``` - -Note that this command starts a new shell and activates the virtual environment. - -As such, `exit` should be used to properly exit the shell and the virtual environment instead of `deactivate`. - -{{% note %}} -Poetry internally uses the [Shellingham](https://github.com/sarugaku/shellingham) project to detect current -active shell. -{{% /note %}} - ## check The `check` command validates the content of the `pyproject.toml` file diff --git a/docs/managing-environments.md b/docs/managing-environments.md index be89afc7c80..74177e79b23 100644 --- a/docs/managing-environments.md +++ b/docs/managing-environments.md @@ -76,6 +76,39 @@ special `system` Python version to retrieve the default behavior: poetry env use system ``` +## Activating the environment + +`poetry env activate` command prints the activate command to the console. This way you won't leave the current shell. +You can then feed the output to `eval` to activate the environment. This way is the closest to manually activating the environment. + +{{% note %}} +Looking for `poetry shell`? It was moved to a plugin: [`poetry-plugin-shell`](https://github.com/python-poetry/poetry-plugin-shell) +{{% /note %}} + +{{< tabs tabTotal="3" tabID1="bash-csh-zsh" tabID2="fish" tabID3="powershell" tabName1="Bash/Zsh/Csh" tabName2="Fish" tabName3="Powershell" }} + +{{< tab tabID="bash-csh-zsh" >}} + + ```bash + $ eval $(poetry env activate) + (test-project-for-test) $ # Virtualenv entered + ``` +{{< /tab >}} +{{< tab tabID="fish" >}} + + ```bash + $ eval (poetry env activate) + ``` +{{< /tab >}} +{{< tab tabID="powershell" >}} + + ```ps1 + PS1> Invoke-Expression (poetry env activate) + ``` + +{{< /tab >}} +{{< /tabs >}} + ## Displaying the environment information If you want to get basic information about the currently activated virtual environment,