| Crates.io | path-munge |
| lib.rs | path-munge |
| version | 1.0.8 |
| created_at | 2025-09-16 18:40:14.689247+00 |
| updated_at | 2025-11-23 17:19:31.775268+00 |
| description | A command-line utility to help set PATH-type shell variables. |
| homepage | |
| repository | https://github.com/adfernandes/path-munge |
| max_upload_size | |
| id | 1842189 |
| size | 41,235 |
This utility is designed to help with managing PATH-type shell variables.
For example, given
$ echo $MANPATH
:/usr/local/man:/home/andrew/.local/share/man
we can prepend directories via
$ path-munge MANPATH prepend force a b c
a:b:c:/usr/local/man:/home/andrew/.local/share/man
or append then via
$ path-munge MANPATH append force a b c
/usr/local/man:/home/andrew/.local/share/man:a:b:c
Note that extra path-separator characters are trimmed from the result.
To use it in your .bashrc, you would need to use it as part of an expansion,
since path-munge never modifies the environment itself.
For example, to prepend /opt/bin and /foo/bar to your path, use
PATH="$(path-munge PATH prepend force /opt/bin /foo/bar)"
In addition to the prepend and append options, you can also use keep
to retain the precedence of a path if it already exists, or use force to
remove its existing precedence and replace it with the new one.
Install with cargo:
cargo install path-munge
or download a binary from the releases page.
MANPATH WarningNote that MANPATH is a bit special. path-munge removes prefix, postfix, and double colons.
However, the man manual page, under "SEARCH PATH" has an interesting note:
If the value of
$MANPATHstarts with a colon, then the default search path is added at its start. If the value of$MANPATHends with a colon, then the default search path is added at its end. If the value of$MANPATHcontains a double colon (::), then the default search path is inserted in the middle of the value, between the two colons.
What this means is that unless you add back a leading or trailing colon when setting MANPATH, you will be unable to search the default system MANPATH!