Crates.io | pathmerge |
lib.rs | pathmerge |
version | 0.0.5 |
source | src |
created_at | 2023-08-20 06:27:59.712981 |
updated_at | 2023-08-20 06:57:10.50815 |
description | cli PATH merging and deduplicating tool |
homepage | |
repository | https://github.com/virgilhuxley/pathmerge |
max_upload_size | |
id | 949216 |
size | 17,299 |
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
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 the PATH
variable.pathmerge
is primarily expected to be called/used by .profiles
and .*rc
files.WIP