From 0a103e24fa7e0de544ab7cff4d3d0d52e620a693 Mon Sep 17 00:00:00 2001 From: Tristan Ancelet Date: Fri, 8 Dec 2023 12:21:51 -0600 Subject: [PATCH] Added config.sh --- scripts/config.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 scripts/config.sh diff --git a/scripts/config.sh b/scripts/config.sh new file mode 100644 index 0000000..85697b7 --- /dev/null +++ b/scripts/config.sh @@ -0,0 +1,26 @@ +#!/usr/local/bin/bash + + +export PROJ_DIR=~/Notes +export JOURNAL_DIR=$PROJ_DIR/wikis +export SCRIPT_DIR=$PROJ_DIR/scripts +export FILES_DIR=$PROJ_DIR/files +export SUBJECTS_DIR=$PROJ_DIR/subjects +export UTILS_DIR=$SCRIPT_DIR/utils + +function import () { + local SCRIPT_NAME="${1:?"import : script name not provided"}" + local SCRIPT_PATH=$UTILS_DIR/$SCRIPT_NAME + + if [[ ! "$SCRIPT_PATH" =~ ^.*\.sh$ ]]; then + SCRIPT_PATH+=".sh" + fi + + if [[ -f $SCRIPT_PATH ]]; then + . $SCRIPT_PATH + else + echo "import : $SCRIPT_PATH does not exist. Exiting program" + exit 1 + fi + +}