bash-it: Add logs to bash-it.sh
parent
9a23725ce0
commit
453c17de3d
28
bash_it.sh
28
bash_it.sh
|
|
@ -1,11 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Initialize Bash It
|
# Initialize Bash It
|
||||||
|
BASH_IT_LOG_PREFIX="core: main: "
|
||||||
|
|
||||||
# Only set $BASH_IT if it's not already set
|
# Only set $BASH_IT if it's not already set
|
||||||
if [ -z "$BASH_IT" ];
|
if [ -z "$BASH_IT" ];
|
||||||
then
|
then
|
||||||
# Setting $BASH to maintain backwards compatibility
|
# Setting $BASH to maintain backwards compatibility
|
||||||
# TODO: warn users that they should upgrade their .bash_profile
|
_log_warning "BASH_IT variable not initialized, please upgrade your bash-it version and reinstall it!"
|
||||||
export BASH_IT=$BASH
|
export BASH_IT=$BASH
|
||||||
BASH="$(bash -c 'echo $BASH')"
|
BASH="$(bash -c 'echo $BASH')"
|
||||||
export BASH
|
export BASH
|
||||||
|
|
@ -14,11 +15,12 @@ fi
|
||||||
# For backwards compatibility, look in old BASH_THEME location
|
# For backwards compatibility, look in old BASH_THEME location
|
||||||
if [ -z "$BASH_IT_THEME" ];
|
if [ -z "$BASH_IT_THEME" ];
|
||||||
then
|
then
|
||||||
# TODO: warn users that they should upgrade their .bash_profile
|
_log_warning "BASH_IT_THEME variable not initialized, please upgrade your bash-it version and reinstall it!"
|
||||||
export BASH_IT_THEME="$BASH_THEME";
|
export BASH_IT_THEME="$BASH_THEME";
|
||||||
unset BASH_THEME;
|
unset BASH_THEME;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
_log_debug "Loading composure..."
|
||||||
# Load composure first, so we support function metadata
|
# Load composure first, so we support function metadata
|
||||||
# shellcheck source=./lib/composure.bash
|
# shellcheck source=./lib/composure.bash
|
||||||
source "${BASH_IT}/lib/composure.bash"
|
source "${BASH_IT}/lib/composure.bash"
|
||||||
|
|
@ -27,11 +29,16 @@ source "${BASH_IT}/lib/composure.bash"
|
||||||
cite _about _param _example _group _author _version
|
cite _about _param _example _group _author _version
|
||||||
|
|
||||||
# libraries, but skip appearance (themes) for now
|
# libraries, but skip appearance (themes) for now
|
||||||
|
_log_debug "Loading libraries(except appearance)..."
|
||||||
LIB="${BASH_IT}/lib/*.bash"
|
LIB="${BASH_IT}/lib/*.bash"
|
||||||
APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash"
|
APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash"
|
||||||
for _bash_it_config_file in $LIB
|
for _bash_it_config_file in $LIB
|
||||||
do
|
do
|
||||||
if [ "$_bash_it_config_file" != "$APPEARANCE_LIB" ]; then
|
if [ "$_bash_it_config_file" != "$APPEARANCE_LIB" ]; then
|
||||||
|
filename=${_bash_it_config_file##*/}
|
||||||
|
filename=${filename%.bash}
|
||||||
|
BASH_IT_LOG_PREFIX="lib: ${filename}: "
|
||||||
|
_log_debug "Loading library file..."
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "$_bash_it_config_file"
|
source "$_bash_it_config_file"
|
||||||
fi
|
fi
|
||||||
|
|
@ -51,36 +58,51 @@ done
|
||||||
|
|
||||||
# Load theme, if a theme was set
|
# Load theme, if a theme was set
|
||||||
if [[ ! -z "${BASH_IT_THEME}" ]]; then
|
if [[ ! -z "${BASH_IT_THEME}" ]]; then
|
||||||
|
_log_debug "Loading \"${BASH_IT_THEME}\" theme..."
|
||||||
# Load colors and helpers first so they can be used in base theme
|
# Load colors and helpers first so they can be used in base theme
|
||||||
|
BASH_IT_LOG_PREFIX="themes: colors: "
|
||||||
# shellcheck source=./themes/colors.theme.bash
|
# shellcheck source=./themes/colors.theme.bash
|
||||||
source "${BASH_IT}/themes/colors.theme.bash"
|
source "${BASH_IT}/themes/colors.theme.bash"
|
||||||
|
BASH_IT_LOG_PREFIX="themes: githelpers: "
|
||||||
# shellcheck source=./themes/githelpers.theme.bash
|
# shellcheck source=./themes/githelpers.theme.bash
|
||||||
source "${BASH_IT}/themes/githelpers.theme.bash"
|
source "${BASH_IT}/themes/githelpers.theme.bash"
|
||||||
|
BASH_IT_LOG_PREFIX="themes: p4helpers: "
|
||||||
# shellcheck source=./themes/p4helpers.theme.bash
|
# shellcheck source=./themes/p4helpers.theme.bash
|
||||||
source "${BASH_IT}/themes/p4helpers.theme.bash"
|
source "${BASH_IT}/themes/p4helpers.theme.bash"
|
||||||
|
BASH_IT_LOG_PREFIX="themes: base: "
|
||||||
# shellcheck source=./themes/base.theme.bash
|
# shellcheck source=./themes/base.theme.bash
|
||||||
source "${BASH_IT}/themes/base.theme.bash"
|
source "${BASH_IT}/themes/base.theme.bash"
|
||||||
|
|
||||||
|
BASH_IT_LOG_PREFIX="lib: appearance: "
|
||||||
# appearance (themes) now, after all dependencies
|
# appearance (themes) now, after all dependencies
|
||||||
# shellcheck source=./lib/appearance.bash
|
# shellcheck source=./lib/appearance.bash
|
||||||
source "$APPEARANCE_LIB"
|
source "$APPEARANCE_LIB"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load custom aliases, completion, plugins
|
BASH_IT_LOG_PREFIX="core: main: "
|
||||||
|
_log_debug "Loading custom aliases, completion, plugins..."
|
||||||
for file_type in "aliases" "completion" "plugins"
|
for file_type in "aliases" "completion" "plugins"
|
||||||
do
|
do
|
||||||
if [ -e "${BASH_IT}/${file_type}/custom.${file_type}.bash" ]
|
if [ -e "${BASH_IT}/${file_type}/custom.${file_type}.bash" ]
|
||||||
then
|
then
|
||||||
|
BASH_IT_LOG_PREFIX="${file_type}: custom: "
|
||||||
|
_log_debug "Loading component..."
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "${BASH_IT}/${file_type}/custom.${file_type}.bash"
|
source "${BASH_IT}/${file_type}/custom.${file_type}.bash"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Custom
|
# Custom
|
||||||
|
BASH_IT_LOG_PREFIX="core: main: "
|
||||||
|
_log_debug "Loading general custom files..."
|
||||||
CUSTOM="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/*.bash ${BASH_IT_CUSTOM:=${BASH_IT}/custom}/**/*.bash"
|
CUSTOM="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/*.bash ${BASH_IT_CUSTOM:=${BASH_IT}/custom}/**/*.bash"
|
||||||
for _bash_it_config_file in $CUSTOM
|
for _bash_it_config_file in $CUSTOM
|
||||||
do
|
do
|
||||||
if [ -e "${_bash_it_config_file}" ]; then
|
if [ -e "${_bash_it_config_file}" ]; then
|
||||||
|
filename=$(basename "${_bash_it_config_file}")
|
||||||
|
filename=${filename%*.bash}
|
||||||
|
BASH_IT_LOG_PREFIX="custom: $filename"
|
||||||
|
_log_debug "Loading custom file..."
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "$_bash_it_config_file"
|
source "$_bash_it_config_file"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue