lib/utilities: autonomize _bash-it-component-item-is-enabled()

This commit is contained in:
John D Pell
2022-01-18 11:06:21 -08:00
parent 22b290b94f
commit 62b5297dc2

View File

@@ -168,12 +168,18 @@ function _bash-it-component-list-disabled() {
# Examples:
# _bash-it-component-item-is-enabled alias git && echo "git alias is enabled"
function _bash-it-component-item-is-enabled() {
local component="$1" item="$2"
local each_file
local component_type item_name each_file
for each_file in "${BASH_IT}/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item}.${component}"*."bash" \
"${BASH_IT}/${component}"*/"enabled/${item}.${component}"*."bash" \
"${BASH_IT}/${component}"*/"enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item}.${component}"*."bash"; do
if [[ -f "${1}" ]]; then
item_name="$(_bash-it-get-component-name-from-path "${1}")"
component_type="$(_bash-it-get-component-type-from-path "${1}")"
else
component_type="${1}" item_name="${2}"
fi
for each_file in "${BASH_IT}/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash" \
"${BASH_IT}/${component_type}"*/"enabled/${item_name}.${component_type}"*."bash" \
"${BASH_IT}/${component_type}"*/"enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash"; do
[[ -f "${each_file}" ]] && return
done
}