-
Notifications
You must be signed in to change notification settings - Fork 0
/
.shellrc
50 lines (40 loc) · 1.06 KB
/
.shellrc
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
export DOTFILES=$(dirname $(readlink $HOME/.shellrc))
function load {
local SILENT=false
for NAME in "$@"; do
local FOUND=false
if [[ $NAME == "--silent" ]]; then
SILENT=true
continue
fi
local SEARCH=(
"$DOTFILES/scripts/$NAME.sh"
"$DOTFILES/scripts/autoload/$NAME.sh"
"$NAME"
)
for SCRIPT in ${SEARCH[@]}; do
if [ -f "$SCRIPT" ]; then
source "$SCRIPT"
FOUND=true
break
fi
done
if [ $SILENT = false -a $FOUND = false ]; then
echo Could not find script $NAME
fi
done
}
function unload {
local UNLOADER="_unload_$1"
if type "$UNLOADER" 2>/dev/null | grep -q 'function' 2>/dev/null; then
$UNLOADER
unset -f $UNLOADER
echo Unloaded $1
else
>&2 echo Unloader for $1 not found
fi
}
# Load initialization script first
load init
# Load the autoload scripts next
load --silent $DOTFILES/scripts/autoload/*.sh