Skip to main content

jnc shell-hook

Prints the shell activation script for a workspace environment. You can source this script to activate the environment in your current shell without starting a new shell session. This is useful for integrating environment activation into CI pipelines, Makefiles, Docker builds, or custom shell scripts.

Usage

jnc shell-hook [OPTIONS]

Options

OptionDescription
-s, --shell <SHELL>The target shell for the activation script. Options: bash, zsh, fish, xonsh. Defaults to the current shell.
-e, --environment <ENV>The environment to generate the activation script for. Defaults to default.
--jsonEmit the environment variables as a JSON object instead of a shell script. Conflicts with --shell.

Update Options

OptionDescription
--frozenUse the lockfile as-is, do not update it.
--lockedRequire the lockfile to be up-to-date, abort if not.
--no-installDo not install the environment before generating the hook.
--as-isShorthand for --frozen --no-install.

Global Options

OptionDescription
-m, --manifest-path <PATH>Path to pixi.toml, pyproject.toml, or the workspace directory.

Examples

Activate in the current bash session

eval "$(jnc shell-hook)"

Generate a script for a specific shell

jnc shell-hook --shell zsh

Activate a specific environment

eval "$(jnc shell-hook --environment cuda)"

Get environment variables as JSON

jnc shell-hook --json

Use in a Dockerfile

RUN jnc install --frozen
RUN eval "$(jnc shell-hook --shell bash)" && python my_script.py

Use in a Makefile

test:
	eval "$$(jnc shell-hook)" && pytest

Use in CI (GitHub Actions)

- run: |
    eval "$(jnc shell-hook)"
    python -c "import numpy; print(numpy.__version__)"