CLI usage#

Run conda spawn --help for details:

usage: conda spawn [-h] [--hook]
                   [--shell {ash,bash,cmd.exe,cmd,csh,dash,fish,posix,powershell,pwsh,tcsh,xonsh,zsh}]
                   [--replace] [--stack]
                   environment [COMMAND [args] ...]

Activate conda environments in new shell processes.

positional arguments:
  environment           Environment to activate. Can be either a name or a
                        path. Paths are only detected if they contain a
                        (back)slash. Use the ./env idiom environments in
                        working directory.
  COMMAND [args]        Optional program to run after starting the shell. Use
                        -- before the program if providing arguments.

options:
  -h, --help            Show this help message and exit.

Shell options:
  --hook                Print the shell activation logic so it can be sourced
                        in-process. This is meant to be used in scripts only.
  --shell {ash,bash,cmd.exe,cmd,csh,dash,fish,posix,powershell,pwsh,tcsh,xonsh,zsh}
                        Shell to use for the new session. If not specified,
                        autodetect shell in use.
  --replace             Spawning shells within conda-spawn shells is
                        disallowed by default. This flag enables nested spawns
                        by replacing the activated environment.
  --stack               Spawning shells within conda-spawn shells is
                        disallowed by default. This flag enables nested spawns
                        by stacking the newly activated environment on top of
                        the current one.

Examples for --hook usage in different shells:
  POSIX:
    source "$(conda spawn --hook ENV-NAME)"
  CMD:
    FOR /F "tokens=*" %%g IN ('conda spawn --hook ENV-NAME') do @CALL %%g
  Powershell:
    conda spawn --hook ENV-NAME | Out-String | Invoke-Expression