Expand description
Safe, idempotent PATH management across shells and operating systems.
onpath lets any Rust CLI tool or installer add directories to the user’s
PATH persistently — across Bash, Zsh, Fish, Nushell, PowerShell, Tcsh, Xonsh,
and Windows (via the registry).
§Quick Start
// Add ~/.myapp/bin to PATH for all detected shells
let report = onpath::add("/home/user/.myapp/bin", "myapp")?;
println!("{report}");§How It Works
On Unix, onpath uses a two-layer approach (pioneered by rustup):
-
Env scripts — Self-guarding shell scripts that check if the directory is already in PATH before adding it (e.g.,
~/.myapp/env,~/.myapp/env.fish). -
Source lines — A single
sourceline added to each shell’s RC file, bracketed with identifiable markers for clean removal.
On Windows, it modifies HKCU\Environment\PATH in the registry and broadcasts
WM_SETTINGCHANGE to notify running applications.
Re-exports§
pub use config::Position;pub use error::Error;pub use manager::PathManager;pub use report::Action;pub use report::ActionKind;pub use report::Report;pub use shell_kind::ShellKind;
Modules§
- config
- PATH position configuration.
- error
- Error types for PATH management operations.
- manager
- The
PathManagerbuilder for configuring PATH operations. - report
- Report types describing actions taken during PATH operations.
- shell_
kind - Shell type identifiers shared across all platforms.
Structs§
- System
Context - System context providing home directory and environment variables.