-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bash_logout
40 lines (28 loc) · 1 KB
/
.bash_logout
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
# kdm bash-env
# .bash_logout
# If ${BASH_ENV_DIR_EXTRA_LOGOUT} isn't populated, return (probably just recently updated the git repo)
[[ -z "${BASH_ENV_DIR_EXTRA_LOGOUT}" ]] && return 0
# If extra-logout dir is missing, create it and then return (it'll be empty anyway)
if [[ ! -d "${BASH_ENV_DIR_EXTRA_LOGOUT}" ]]; then
mkdir -p "${BASH_ENV_DIR_EXTRA_LOGOUT}"
return 0
fi
# Source bash libraries from ~/.kdm/extra-logout
mapfile -t ARRAY_LOGOUT < <(find -L "${BASH_ENV_DIR_EXTRA_LOGOUT}" -maxdepth 1 -type f -executable 2> /dev/null | sort)
for ENTRY in "${ARRAY_LOGOUT[@]}"; do
# Skip README
[[ "${ENTRY}" == "README" ]] && continue
unset SOURCE_EXIT
unset SOURCE_FILE
# shellcheck disable=SC1090
. "${ENTRY}"; SOURCE_EXIT="${?}"
[[ "${SOURCE_VERBOSE}" != "true" ]] && continue
SOURCE_FILE="${ENTRY/${HOME}\/\.kdm\//}"
if [[ "${SOURCE_EXIT}" == "0" ]]; then
output keyval-p "Loaded" "${SOURCE_FILE}"
continue
fi
output keyval-f "Failed" "${SOURCE_FILE}"
done
unset SOURCE_EXIT
unset SOURCE_FILE