-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc.interactive
71 lines (58 loc) · 1.99 KB
/
bashrc.interactive
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
64
65
66
67
68
69
70
#!bash
# vim:set ft=sh tabstop=2 softtabstop=2 shiftwidth=2 expandtab autoindent copyindent :
# The bashrc.other_rc_directories file in this directory
# could say something like this:
# OTHER_RC_DIRS+=( "$HOME/.rc-private" )
# Better yet though, create symlinks in
# bashrc.other_rc_directories.d/.
OTHER_RC_DIRS=()
if [ -r "$this_bashdir"/bashrc.other_rc_directories ]
then
. "$this_bashdir"/bashrc.other_rc_directories
fi
RC_public="$this_bashdir"
bash_RC_public="$RC_public/bashrc.d"
# read all files in bashrc.d/ that don't end in .README
declare bashdotd_filenames=()
mapfile -d $'\0' bashdotd_filenames < <( find "${bash_RC_public}/" -maxdepth 1 -type f ! -name \*.sw? ! -name \*.README ! -name \*.md ! -name README ! -name .\* -print0 | LC_ALL=C sort -z )
for bashdotd_filename in "${bashdotd_filenames[@]}"
do
if [ -r "$bashdotd_filename" ] ; then . "$bashdotd_filename" ; fi
done
unset bashdotd_filename bashdotd_filenames
# Append to OTHER_RC_DIRS any symlinked directories found in bashrc.other_rc_directories.d.
declare other_rc_dirs=()
mapfile -d $'\0' other_rc_dirs < <( find "${this_bashdir}"/bashrc.other_rc_directories.d/ -type l -print0 | LC_ALL=C sort -z )
for other_rc_dir in "${other_rc_dirs[@]}"
do
if [ -d "$other_rc_dir" ]
then
OTHER_RC_DIRS+=( "$other_rc_dir" )
fi
done
unset other_rc_dirs
# Call any bashrc.interactive files from OTHER_RC_DIRS.
declare -A rcdir_used # used to avoid calling a file more than once
rcdir_used["$(abspath "${BASH_SOURCE[0]}")"]=1
for other_rc_dir in "${OTHER_RC_DIRS[@]}"
do
other_rc_dir_abs="$(abspath "$other_rc_dir/bashrc.interactive" )"
# echo "candidate($other_rc_dir_abs)" 1>&2
if [ -n "${rcdir_used[$other_rc_dir_abs]}" ]
then
# echo " duplicate" 1>&2
continue
fi
rcdir_used[$other_rc_dir_abs]=1
if [ -r "${other_rc_dir_abs}" ]
then
# echo " reading" 1>&2
pushd "$other_rc_dir" >/dev/null
. "${other_rc_dir_abs}"
popd >/dev/null
else
:
# echo " unreadable" 1>&2
fi
done
unset rcdir_used