feat: x-path-* as scripts, run other changes

This commit is contained in:
2023-11-01 14:45:03 +02:00
parent cec1edb269
commit 4572c42eea
12 changed files with 109 additions and 110 deletions

View File

@@ -3,7 +3,7 @@
which "$1" >&/dev/null
if [ $? -eq 0 ]; then
echo 0
exit 0
else
echo 1
exit 1
fi

8
local/bin/x-path-append Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
#
# Add a directory to the beginning of the PATH if it's not already there.
# Usage: x-path-append <dir>
x-path-remove "$1"
export PATH="${PATH:+"$PATH:"}$1"

7
local/bin/x-path-prepend Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
#
# Add a directory to the front of the PATH if it exists and is not already there
# Usage: x-path-prepend <dir>
export PATH="$1${PATH:+":$PATH"}"

7
local/bin/x-path-remove Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
#
# Remove a directory from the PATH
# Usage: x-path-remove <dir>
export PATH=$(echo -n "$PATH" | awk -v RS=: -v ORS=: "\$0 != \"$1\"" | sed 's/:$//')