]> CyberLeo.Net >> Repos - CDN/bash-config.git/blob - bash-config/common
Include ~/.bash_profile.d and ~/.bashrc.d when loading subfiles
[CDN/bash-config.git] / bash-config / common
1 # Set up _base, _self first
2
3 # Keep track of which config set is loaded, to avoid loading a config set more than once
4 if [ -z "${__BASH_CONFIG_LOADED}" ] || echo "${__BASH_CONFIG_LOADED}" | grep -qv " ${_self} "
5 then
6   __BASH_CONFIG_LOADED="${__BASH_CONFIG_LOADED} ${_self} "
7
8   # Interactive shell?
9   _i() { [[ $- == *i* ]]; return $?; }
10
11   # Include all subfiles, in lexicographical order
12   eval "$(
13     (
14       [ -d "${_base}/${_self}.d/" ] && echo "${_base}/${_self}.d/"
15       [ -d "${HOME}/.${_self}.d/" ] && echo "${HOME}/.${_self}.d/"
16     ) | while read _path
17     do
18       find ${_path} -type f | sort
19     done | sed -e 's/^/source /; s/$/;/'
20   )"
21
22   unset _base _self _i
23 fi