Usage: pathmerge [OPTIONS] [paths]...
Arguments:
[paths]... list of paths to include
Options:
-d, --delimiter <delimiter> Specify delimiter to use, bash ':', fish ' ' [default: :]
-p, --path <path> Path string [env: PATH=/home/user/bin:/usr/bin:/usr/local/bin:/usr/local/sbin]
-s, --sort If the resulting output should be sorted
-h, --help Print help
-V, --version Print version
PATH="/path1:/path2:/path3"
PATH="$(pathmerge /path4)"
echo $PATH
# output
/path1:/path2:/path3:/path4
NEWPATH="$(pathmerge --path /a:/b:/c /z)"
echo $NEWPATH
# output
/a:/b:/c:/z
UGLYPATH="/a:/b:/c:/a:/a:/c:/b:/c"
CLEANPATH="$(pathmerge --path $UGLYPATH)"
echo $CLEANPATH
# output
/a:/b:/c
PATH="/a /b /c /c /c"
NEWPATH="$(pathmerge --delimiter ' ' /z)"
echo $NEWPATH
# output
/a /b /c /z
PATH="/c:/a:/b"
NEWPATH="$(pathmerge --sort)"
echo $PATH
# output
/a:/b:/c
- Specifying the
delimiter
does not cause the output to change the delimiter, only what the logic triggers off of. pathmerge
does not modify anything in the shell or environment, it only allows you to manipulate PATH formatted strings and outputs those strings. It is still up to the user to push those strings into their appropriate environment variable. e.g.PATH=$(pathmerge)
to read from env, Deduplicate then push back into thePATH
variable.pathmerge
is primarily expected to be called/used by.profiles
and.*rc
files.
WIP