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.
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.
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
pato is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.