Bash PATH manipulation functions
Shell Perl
Switch branches/tags
Nothing to show
Latest commit 11feac3 Aug 22, 2011 @ingydotnet remove deprecated code
Failed to load latest commit information.
tests refactored with gabimuc++ Aug 22, 2011
.proverc Full module with code, doc and tests Apr 30, 2011
Changes v0.01 Apr 30, 2011
LICENSE first commit Apr 30, 2011
Makefile Full module with code, doc and tests Apr 30, 2011
README.rst v0.01 Apr 30, 2011 remove deprecated code Aug 22, 2011





This bash module is a set of functions to list, prepend, append and remove elements from your PATH environment variable. It will also work with other colon separated PATH-like environment variables like PERL5LIB and PYTHONPATH, etc.

When components are added to a PATH, they are first removed if they already exist. This keeps the PATH from containing multiple references to the same component. That means you can run the same path modifying script multiple times, without your PATH growing out of control.


In your .bashrc:

source `which`
path-prepend /path/to/some/new/bin/
path-append $HOME/perl5/lib PERL5LIB


The Makefile will let you run the tests and install the module:

> make test
> sudo make install


Each of these functions can take an optional final argument, naming the environment variable to operate on. The default environment variable is PATH, of course.

path-list [<variable>]:
List all the components of a PATH variable, one per line
path-remove <component> [<variable>]:
Remove specified component from a PATH variable
path-prepend <component> [<variable>]:
Add component to beginning of a PATH (after removing any instances of it)
path-append <component> [<variable>]:
Add component to end of PATH (after removing any instances of it)


This code can be found at

See Also


Ingy dot Net <>


Copyright © 2011. Ingy dot Net


This library is free software, distributed under the ISC License. See the LICENSE file distributed with this library.