Skip to content

Instantly share code, notes, and snippets.

@tytydraco
Last active July 16, 2020 23:02
Show Gist options
  • Save tytydraco/934b057d12c64f59fa81ea5b5d7b1840 to your computer and use it in GitHub Desktop.
Save tytydraco/934b057d12c64f59fa81ea5b5d7b1840 to your computer and use it in GitHub Desktop.
A wrapper for easy portable ChArch usage.
# Written by Draco (tytydraco) @ GitHub
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# ChArch local bin path
BINPATH="$SCRIPTPATH/bin"
# Options to pass to ChArch commands
CHARCH_OPTS="-d $SCRIPTPATH"
# Add local bins to path
[[ "$PATH" != *"$BINPATH"* ]] && export PATH="$BINPATH:$PATH"
# Pull bins if necessary
if [[ ! -d "$BINPATH" ]]
then
mkdir "$BINPATH"
git clone https://github.com/tytydraco/ChArch.git "$BINPATH"
fi
# Pull newest changes
git -C "$BINPATH" pull
# Check for root permissions
if [[ `id -u` -ne 0 ]]
then
echo "[!] This wrapper should be sourced as root."
fi
charch() {
"$BINPATH/charch" $CHARCH_OPTS $@
}
cparch() {
"$BINPATH/cparch" $CHARCH_OPTS $@
}
lsarch() {
"$BINPATH/lsarch" $CHARCH_OPTS $@
}
rmarch() {
"$BINPATH/rmarch" $CHARCH_OPTS $@
}
unarch() {
"$BINPATH/unarch" $CHARCH_OPTS $@
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment