-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource-relevant-files
executable file
·39 lines (31 loc) · 1.04 KB
/
source-relevant-files
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# vim: filetype=sh
# this SEEMS to behave sensibly, and the same way in both bash and zsh
# apologies if I messed something up!
# current shell with leading '-' removed
shell=${SHELL##*/}
# where we are now; https://stackoverflow.com/a/54755784
scriptname=${BASH_SOURCE[0]:-${(%):-%x}}
shellrcddir=$(dirname $scriptname)
if [ -f "${shellrcddir}/debug-on" ]; then
export SHELLRCD_DEBUG=1
else
unset SHELLRCD_DEBUG
fi
# start with a list of no files at all
files=()
# check places we expect to find things
for maybe_subdir in _PRIVATE _agnostic "${shell}"; do
if [ -d "${shellrcddir}/${maybe_subdir}" ]; then
files+=(${shellrcddir}/${maybe_subdir}/*)
fi
done
for x in "${files[@]}"; do
if [ -n "$SHELLRCD_DEBUG" ]; then echo "[DEBUG][${x//.\//}] found file"; fi
test -f "$x" || continue
test -x "$x" || continue
if [ -n "$SHELLRCD_DEBUG" ]; then echo "[DEBUG][${x//.\//}] sourcing file..."; fi
#source "$x" >/dev/null 3>&2
source "$x"
done
# explicity unset shellrcddir; it's hanging around for some reason
unset shellrcddir