-
Notifications
You must be signed in to change notification settings - Fork 2
/
root.bash
63 lines (56 loc) · 1.5 KB
/
root.bash
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
path-abs() {
cd -P "$(dirname "${1}")" && pwd
}
path-read-link() {
case "$(uname)" in
"Darwin")
readlink -n "${1}"
;;
"Linux")
readlink --canonicalize-existing --no-newline "${1}"
;;
*)
readlink -n "${1}"
;;
esac
}
path-real() {
local SOURCE="${1}"
while [[ -L ${SOURCE} ]]; do
SOURCE="$(path-read-link "${SOURCE}")"
[[ ${SOURCE} != /* ]] && SOURCE="$(path-abs "${SOURCE}")/${SOURCE}"
done
path-abs "${SOURCE}"
}
DOTFILES_PATH="$(path-real "${BASH_SOURCE[0]}")"
export DOTFILES_PATH
################################################################################
######### Source libs ##########################################################
for src in "${DOTFILES_PATH}"/lib/*.bash; do
if [[ -r ${src} ]]; then
# https://www.shellcheck.net/wiki/SC1090
# shellcheck source=/dev/null
source "${src}"
fi
done
unset src
for src in "${DOTFILES_PATH}"/extras-*; do
# https://www.shellcheck.net/wiki/SC1090
# shellcheck source=/dev/null
source "${src}"
done 2>/dev/null
unset src
if [[ -d "${HOME}"/.bashrc.d ]]; then
for src in "${HOME}"/.bashrc.d/*; do
if [[ -f ${src} ]]; then
# https://www.shellcheck.net/wiki/SC1090
# shellcheck source=/dev/null
source "${src}"
fi
done
fi
unset src
################################################################################
################################################################################
path-add "${DOTFILES_PATH}/bin"
path-add "${HOME}/bin"