Command-line tool to manipulate a PATH variable
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
dist
doc
test
.travis.yml
LICENSE
README.adoc

README.adoc

pato

travis

Command-line tool to manipulate a PATH variable.

Motivation

The format of the PATH environment variable with colon separated values allows you easy to add a new path at the front or end. But all other operations(swap, remove) require the help of an editor and some manual moves. pato is my approach to solve this problem.

Usage

List all paths that are stored in a PATH variable:

$ pato -e list                // lists the values of the PATH variable from the environment
$ pato list                   // same as -e
$ echo $PATH | pato -i list   // lists the values of the PATH variable from the input stream

Manipulate a PATH variable and set it as the environment PATH variable:

$ PATH=$( pato push $PWD )
$ PATH=$( pato pushf $PWD )
$ PATH=$( pato insert 2 $PWD )
$ PATH=$( pato remove 3 )
$ PATH=$( pato swap 2 6 )

All commands that manipulate a PATH variable write the result as a line to the output stream. So it is easy to chain commands together:

$ PATH=$( pato push $PWD | pato -i push $PWD/bin | pato -i push $PWD/tools )

Check the manpage in the doc directory for further information about the usage.

Installation

Use just the following line to get the latest release.

luarocks install pato

If you want to use the current development version, clone this repository and use LuaRocks with the following command.

luarocks make dist/pato-scm-0.rockspec

License

pato is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.