| Crates.io | what-the-path |
| lib.rs | what-the-path |
| version | 0.1.4 |
| created_at | 2024-11-03 11:15:52.598906+00 |
| updated_at | 2025-07-18 10:13:00.6795+00 |
| description | A rust library for easily adding paths to $PATH on UNIX |
| homepage | |
| repository | https://github.com/MordechaiHadad/what-the-path |
| max_upload_size | |
| id | 1433595 |
| size | 21,792 |
A Rust library for detecting the current Unix shell, managing shell rc files, and manipulating your PATH.
.bashrc, .zshenv, conf.d for fish, etc.)PATH environment variableAdd to your Cargo.toml:
[dependencies]
what-the-path = "0.1"
use what_the_path::{Shell, exists_in_path, append_to_rcfile, remove_from_rcfile};
use std::path::PathBuf;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Detect current shell and list rc files
let shell = Shell::detect_by_shell_var()?;
let rcfiles = shell.get_rcfiles()?;
println!("Detected shell: {:?}\nRC files: {:?}", shell, rcfiles);
// Check if directory is in PATH
let dir = "/usr/local/bin";
if exists_in_path(dir) {
println!("{} is in PATH", dir);
}
// Append a line to an rc file
let rc = PathBuf::from("/home/user/.bashrc");
append_to_rcfile(rc.clone(), "export FOO=bar")?;
// Remove a line from an rc file
remove_from_rcfile(rc, "export FOO=bar")?;
Ok(())
}