-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sh
71 lines (56 loc) · 1.3 KB
/
init.sh
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
71
#!/bin/bash
bfg_check_environment() {
if [ -z "$BFG_SHELL_HOME" ]; then
echo
echo "ERROR!"
echo
echo "Could not initialize BFG Shell because the \$BFG_SHELL_HOME"
echo "environment variable is not set."
echo
exit 1
fi
}
bfg_run() {
local target=""
target="$BFG_SHELL_HOME"/scripts/"$1".sh
if [ -n "$ZSH_VERSION" ]; then
zsh "$target" "${@:2}"
else
bash "$target" "${@:2}"
fi
}
bfg_source() {
source "$BFG_SHELL_HOME/$1.sh"
}
bfg_smart_source() {
local target=""
local detected_shell=""
target="$BFG_SHELL_HOME/$1"
detected_shell="bash"
if [ -n "$ZSH_VERSION" ]; then
detected_shell="zsh"
fi
if [ -f "$target.sh" ]; then
source "$target.sh"
fi
if [ -f "$target""_""$detected_shell.sh" ]; then
source "$target""_""$detected_shell.sh"
fi
}
bfg_init() {
bfg_check_environment
bfg_smart_source "alias"
bfg_smart_source "func"
bfg_smart_source "config"
bfg_smart_source "escape"
bfg_smart_source "prompt"
bfg_source "update"
bfg_smart_source "local/alias"
bfg_smart_source "local/config"
}
bfg_reload() {
bfg_check_environment
bfg_source "init"
bfg_init
echo "BFG Shell has been re-initialized."
}