path-munge

Crates.iopath-munge
lib.rspath-munge
version1.0.8
created_at2025-09-16 18:40:14.689247+00
updated_at2025-11-23 17:19:31.775268+00
descriptionA command-line utility to help set PATH-type shell variables.
homepage
repositoryhttps://github.com/adfernandes/path-munge
max_upload_size
id1842189
size41,235
Andrew Fernandes (adfernandes)

documentation

README

path-munge

Crates.io Crates.io License: MPL 2.0 Release Workflow

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.

Usage

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.

Installation

Install with cargo:

cargo install path-munge

or download a binary from the releases page.

MANPATH Warning

Note 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 $MANPATH starts with a colon, then the default search path is added at its start. If the value of $MANPATH ends with a colon, then the default search path is added at its end. If the value of $MANPATH contains 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!

Commit count: 2

cargo fmt