[cleanup] Harmonized variable names, added support for global config files
parent
2f3d4bd130
commit
f06439edc3
29
bash_it.sh
29
bash_it.sh
|
|
@ -29,31 +29,28 @@ cite _about _param _example _group _author _version
|
|||
# libraries, but skip appearance (themes) for now
|
||||
LIB="${BASH_IT}/lib/*.bash"
|
||||
APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash"
|
||||
for config_file in $LIB
|
||||
for _bash_it_config_file in $LIB
|
||||
do
|
||||
if [ "$config_file" != "$APPEARANCE_LIB" ]; then
|
||||
if [ "$_bash_it_config_file" != "$APPEARANCE_LIB" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$config_file"
|
||||
source "$_bash_it_config_file"
|
||||
fi
|
||||
done
|
||||
|
||||
# Load the global "enabled" directory
|
||||
_load_global_bash_it_files
|
||||
# "family" param is empty so that files get sources in glob order
|
||||
for _bash_it_config_file in $(_list_global_bash_it_files "") ; do
|
||||
. "${BASH_IT}/$_bash_it_config_file"
|
||||
done
|
||||
|
||||
# Load enabled aliases, completion, plugins
|
||||
for file_type in "aliases" "plugins" "completion"
|
||||
do
|
||||
_bash_it_list_bash_it_files_return=()
|
||||
_list_bash_it_files $file_type
|
||||
|
||||
for config_file in "${_bash_it_list_bash_it_files_return[@]}" ; do
|
||||
. "$config_file"
|
||||
for _bash_it_config_file in $(_list_bash_it_files "$file_type") ; do
|
||||
. "${BASH_IT}/$_bash_it_config_file"
|
||||
done
|
||||
done
|
||||
|
||||
unset _bash_it_list_bash_it_files_return
|
||||
unset _bash_it_config_file
|
||||
|
||||
# Load theme, if a theme was set
|
||||
if [[ ! -z "${BASH_IT_THEME}" ]]; then
|
||||
# Load colors and helpers first so they can be used in base theme
|
||||
|
|
@ -83,15 +80,15 @@ done
|
|||
|
||||
# Custom
|
||||
CUSTOM="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/*.bash ${BASH_IT_CUSTOM:=${BASH_IT}/custom}/**/*.bash"
|
||||
for config_file in $CUSTOM
|
||||
for _bash_it_config_file in $CUSTOM
|
||||
do
|
||||
if [ -e "${config_file}" ]; then
|
||||
if [ -e "${_bash_it_config_file}" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$config_file"
|
||||
source "$_bash_it_config_file"
|
||||
fi
|
||||
done
|
||||
|
||||
unset config_file
|
||||
unset _bash_it_config_file
|
||||
if [[ $PROMPT ]]; then
|
||||
export PS1="\[""$PROMPT""\]"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -17,42 +17,54 @@ function _command_exists ()
|
|||
# Helper function listing various enable-able files to be sourced
|
||||
# The files need to be sourced in global scope to preserve scope of 'declare'
|
||||
function _list_bash_it_files() {
|
||||
subdirectory="$1"
|
||||
if [ -d "${BASH_IT}/${subdirectory}/enabled" ]
|
||||
local subdirectory="$1"
|
||||
pushd "${BASH_IT}" >/dev/null
|
||||
|
||||
if [ -d "./${subdirectory}/enabled" ]
|
||||
then
|
||||
FILES="${BASH_IT}/${subdirectory}/enabled/*.bash"
|
||||
local FILES="./${subdirectory}/enabled/*.bash"
|
||||
local _bash_it_config_file
|
||||
|
||||
for _bash_it_config_file in $FILES
|
||||
do
|
||||
if [ -e "${_bash_it_config_file}" ]; then
|
||||
_bash_it_list_bash_it_files_return+=("$_bash_it_config_file")
|
||||
printf "$_bash_it_config_file\n"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
function _load_global_bash_it_files() {
|
||||
function _list_global_bash_it_files() {
|
||||
local family="$1"
|
||||
pushd "${BASH_IT}" >/dev/null
|
||||
|
||||
# In the new structure
|
||||
if [ -d "${BASH_IT}/enabled" ]
|
||||
if [ -d "./enabled" ]
|
||||
then
|
||||
FILES="${BASH_IT}/enabled/*.bash"
|
||||
for config_file in $FILES
|
||||
local FILES="./enabled/*$family.bash"
|
||||
local _bash_it_config_file
|
||||
|
||||
for _bash_it_config_file in $FILES
|
||||
do
|
||||
if [ -e "${config_file}" ]; then
|
||||
source $config_file
|
||||
if [ -e "${_bash_it_config_file}" ]; then
|
||||
printf "$_bash_it_config_file\n"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function _make_reload_alias() {
|
||||
printf %s '\
|
||||
_bash_it_list_bash_it_files_return=() ;\
|
||||
_list_bash_it_files '"$1"' ;\
|
||||
for _bash_it_config_file in "${_bash_it_list_bash_it_files_return[@]}"; do \
|
||||
. "$_bash_it_config_file" ;\
|
||||
done ;\
|
||||
unset _bash_it_list_bash_it_files_return ;\
|
||||
printf %s '
|
||||
|
||||
for _bash_it_config_file in $(_list_global_bash_it_files '"$1"'); do \
|
||||
. "${BASH_IT}/$_bash_it_config_file" ;
|
||||
done ;
|
||||
|
||||
for _bash_it_config_file in $(_list_bash_it_files '"$1"'); do
|
||||
. "${BASH_IT}/$_bash_it_config_file" ;
|
||||
done ;
|
||||
unset _bash_it_config_file'
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue