Metadata-Version: 2.4
Name: pathreg
Version: 1.0.2
Summary: A lightweight Python library to persistently add or remove directories from PATH.
Author-email: TN3W <tn3w@protonmail.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/tn3w/pathreg
Project-URL: Repository, https://github.com/tn3w/pathreg.git
Project-URL: Issues, https://github.com/tn3w/pathreg/issues
Keywords: path,environment,shell,cli
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: black>=25.1.0; extra == "dev"
Requires-Dist: pytest>=8.4.1; extra == "dev"
Requires-Dist: pytest-cov>=6.2.1; extra == "dev"
Dynamic: license-file

# pathreg

Persistently add or remove directories from `PATH` on Windows, Linux, and macOS.

## Installation

```sh
pip install pathreg
```

## CLI Usage

```sh
pathreg add /some/directory
pathreg remove /some/directory
pathreg list
pathreg check /some/directory   # prints "yes" or "no"
```

## Python API

```python
from pathreg import add_path, remove_path, list_paths, in_path

add_path("/some/directory")     # idempotent, skips if already present
remove_path("/some/directory")  # no-op if not found
list_paths()                    # returns list[Path] of current PATH entries
in_path("/some/directory")      # returns True if directory is in PATH
```

`add_path` and `remove_path` modify the shell profile **and** the current process's `PATH` immediately.

## Behavior

- Paths are normalized: trailing separators stripped, slashes converted per platform.
- `add_path` is idempotent, does nothing if the entry already exists.
- `remove_path` is a no-op if the entry is absent or the profile file does not exist.
- `list_paths` reflects the current process `PATH`; it does not read the profile file.
- `in_path` normalizes trailing separators before comparing, matching `add_path` behaviour.

## Platform support

| Platform | Persistence target                                                                 |
| -------- | ---------------------------------------------------------------------------------- |
| Windows  | `HKCU\Environment` via `winreg`; broadcasts `WM_SETTINGCHANGE` to notify the shell |
| bash     | `~/.bash_profile` (falls back to `~/.profile` if it exists)                        |
| zsh      | `~/.zshenv`                                                                        |
| sh       | `~/.profile`                                                                       |

The active shell is detected from the `SHELL` environment variable.

No third-party dependencies required.
