From d60da53cafc9a6ee6b4031437796628ee36bc7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20B=C3=BCckendorf?= Date: Mon, 17 Dec 2018 02:38:07 +0100 Subject: [PATCH] bashrc: built the structure to add utility functions for the bashrc in the future. --- .bashrc | 10 +++++++++- .dotfiles/bash_functions.sh | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .dotfiles/bash_functions.sh diff --git a/.bashrc b/.bashrc index 8c47013..9b8ccd8 100644 --- a/.bashrc +++ b/.bashrc @@ -51,15 +51,23 @@ function true_false_default { export -f truthy falsy true_false_default +# Now that we have the bare essentials, determine if the rest of the configura- +# tion should be loaded. DOTFILES_ACTIVE is a environment variable that can be +# set in ~/.environment.d/dotfiles.env if truthy $DOTFILES_ACTIVE; then - # Source .bashrc.d + # Load utilty functions that may be used by other configurations + . "$DOTFILES_DIR/bash_functions.sh" + + # Load the rest of the bash configs in ~/.basrc.d for file in ~/.bashrc.d/*.sh; do . "$file" done unset -v file +# If the DOTFILES_ACTIVE is not set at all, assume that the dotfiles repo was +# cloned very recently and print a friendly reminder. elif [[ ! -v DOTFILES_ACTIVE ]]; then echo "Dotfiles environment not found." >&2 echo "You should probably reload your login session before proceeding." >&2 diff --git a/.dotfiles/bash_functions.sh b/.dotfiles/bash_functions.sh new file mode 100644 index 0000000..c121a0f --- /dev/null +++ b/.dotfiles/bash_functions.sh @@ -0,0 +1,3 @@ +function dot_msg { + echo "$@" +}