> ## Documentation Index
> Fetch the complete documentation index at: https://jncpkg.org/llms.txt
> Use this file to discover all available pages before exploring further.

# jnc shell-hook

> Print the environment activation script for use in shell configurations.

# 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

```bash theme={null}
jnc shell-hook [OPTIONS]
```

## Options

| Option                      | Description                                                                                                         |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `-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`.                                       |
| `--json`                    | Emit the environment variables as a JSON object instead of a shell script. Conflicts with `--shell`.                |

### Update Options

| Option         | Description                                                |
| -------------- | ---------------------------------------------------------- |
| `--frozen`     | Use the lockfile as-is, do not update it.                  |
| `--locked`     | Require the lockfile to be up-to-date, abort if not.       |
| `--no-install` | Do not install the environment before generating the hook. |
| `--as-is`      | Shorthand for `--frozen --no-install`.                     |

### Global Options

| Option                         | Description                                                       |
| ------------------------------ | ----------------------------------------------------------------- |
| `-m`, `--manifest-path <PATH>` | Path to `jnc.toml`, `pyproject.toml`, or the workspace directory. |

## Examples

### Activate in the current bash session

```bash theme={null}
eval "$(jnc shell-hook)"
```

### Generate a script for a specific shell

```bash theme={null}
jnc shell-hook --shell zsh
```

### Activate a specific environment

```bash theme={null}
eval "$(jnc shell-hook --environment cuda)"
```

### Get environment variables as JSON

```bash theme={null}
jnc shell-hook --json
```

### Use in a Dockerfile

```dockerfile theme={null}
RUN jnc install --frozen
RUN eval "$(jnc shell-hook --shell bash)" && python my_script.py
```

### Use in a Makefile

```makefile theme={null}
test:
	eval "$$(jnc shell-hook)" && pytest
```

### Use in CI (GitHub Actions)

```yaml theme={null}
- run: |
    eval "$(jnc shell-hook)"
    python -c "import numpy; print(numpy.__version__)"
```
