-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.bash
65 lines (53 loc) · 1.2 KB
/
index.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
64
65
#
# Setup check
#
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
THIS_COMPLETION=~/.dotfiles/completion
THIS_MODULES=~/.dotfiles/modules
LOCAL_MODULES=~/.dotfiles.local
function load_modules() {
# Terminal session without X
SHARED_MODULES=(
'aliases.bash'
'setup.bash'
'functions.bash'
)
# Terminal session inside X
NONLOGIN_MODULES=(
'colors.bash'
'kubernetes.bash'
'prompt.bash'
'fzf.bash'
'init.bash'
)
for MODULE in ${SHARED_MODULES[@]}; do
[ -f $1/$MODULE ] && source $1/$MODULE
done
# Text only sessions, but not SSH sessions
if [[ ! -z "$BASH_NONLOGIN" || $(tty) == "$SSH_TTY" ]]; then
for MODULE in ${NONLOGIN_MODULES[@]}; do
[ -f $1/$MODULE ] && source $1/$MODULE
done
fi
}
function load_completion() {
COMPLETION_MODULES=(
'aliases.bash'
'git.bash'
)
for MODULE in ${COMPLETION_MODULES[@]}; do
[ -f $THIS_COMPLETION/$MODULE ] && source $THIS_COMPLETION/$MODULE
done
}
# Configure from local modules
if [[ -f $LOCAL_MODULES/configure.bash ]]; then
source $LOCAL_MODULES/configure.bash
fi
# Default modules
load_modules $THIS_MODULES
load_completion
# Local modules
if [[ -d $LOCAL_MODULES ]]; then
load_modules $LOCAL_MODULES
fi