aboutsummaryrefslogtreecommitdiffstats
path: root/ves-init.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ves-init.sh')
-rw-r--r--ves-init.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/ves-init.sh b/ves-init.sh
new file mode 100644
index 0000000..e323aaa
--- /dev/null
+++ b/ves-init.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+#
+# Initialize the sh-ves system within a shell session by sourcing the relevant
+# files to add function definitions for functionality that cannot be
+# implemented via scripts, as well as initialing some local variables used by
+# the system. This file should be sourced in your shell's rc or profile file.
+#
+# Note, the correct functioning of other sh-ves functions requires that this
+# file be sourced prior to calling them. As such, they will check for
+# SH_VES_INIT to be created prior to doing anything. If is not suggested to try
+# to set this variable manually to get around sourcing this file.
+#
+# This file also provides default values for several sh-ves configuration
+# variables. You may override these settings by setting the variables
+# prior to sourcing this file, in which case they will not be modified,
+# or by overwriting their values after sourcing the file.
+
+if [ -z "${XDG_DATA_HOME+x}" ]; then
+ SHVES_ENV_DIR="$HOME/.local/share/ves/envs"
+else
+ SHVES_ENV_DIR="$XDG_DATA_HOME/ves/envs"
+fi
+
+if [ -z "${SHVES_OVERRIDE_VARS+x}" ]; then
+ SHVES_OVERRIDE_VARS="PATH LDPATH LD_LIBRARY_PATH CPATH"
+fi
+
+if [ -z "${SHVES_SCRIPTS_DIR+x}" ]; then
+ SHVES_BIN="$HOME/.local/bin/ves_scripts"
+else
+ SHVES_BIN="$SHVES_SCRIPTS_DIR"
+fi
+
+_shves_check_env_name() {
+ if ! echo $1 | grep "^[[:alpha:][:digit:]_-]*$" > /dev/null; then
+ printf "ERROR: Environment [%s] is invalid. Name must contain only letters, -, and _\n" $1 > /dev/stderr
+ return 1
+ fi
+
+ return 0
+}
+
+
+_shves_check_env_exists() {
+ if [ ! -f "$SHVES_ENV_DIR/$1" ]; then
+ if [ "$#" -lt 2 ]; then
+ printf "ERROR: Environment [%s] does not exist.\n" $1 > /dev/stderr
+ fi
+
+ return 1
+ fi
+
+ return 0
+}
+
+. "$SHVES_BIN"/ves.sh
+. "$SHVES_BIN"/ves-export.sh
+. "$SHVES_BIN"/ves-activate.sh
+. "$SHVES_BIN"/ves-deactivate.sh
+. "$SHVES_BIN"/ves-var-add.sh
+. "$SHVES_BIN"/ves-var-rm.sh
+. "$SHVES_BIN"/ves-create.sh
+. "$SHVES_BIN"/ves-delete.sh
+
+