-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotfunctions.zsh
77 lines (61 loc) · 1.87 KB
/
dotfunctions.zsh
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
72
73
74
75
76
77
function debug {
if [[ "$DOTFILE_DEBUG" == "true" ]]; then
echo $@ >> /tmp/dotfile.log
fi
}
function update_dotfile_config_files {
DOT=${DOTFILES:=~/.dotfiles}
find $DOT -maxdepth 2 -name "*.zsh" -not -name "dotfunctions.zsh" > $DOT/.config_files
}
function dotfile_config_files {
if [ -z "$DOTFILE_CONFIG_FILES" ]; then
if [ ! -f $DOTFILES/.config_files ]; then
update_dotfile_config_files
fi
export DOTFILE_CONFIG_FILES=$(cat $DOTFILES/.config_files)
fi
}
function set_debug_mode {
if [[ -f "/tmp/dotfiles.debug" ]]; then
export DOTFILE_DEBUG="true"
echo "DEBUG enabled"
else
export DOTFILE_DEBUG="false"
fi
}
function load_path_config {
debug "Loading path config files..."
for file in ${(M)${(@f)DOTFILE_CONFIG_FILES}:#*/path.zsh}; do
debug "Processing path config $file..."
if ! [[ "$file" =~ '.*\.symlink$' ]]; then
debug "Loading path config: $file"
source $file
fi
done
}
function load_env_config {
debug "Loading env config files..."
for file in ${(M)${(@f)DOTFILE_CONFIG_FILES}:#*/env.zsh}; do
debug "Processing env config $file..."
if ! [[ "$file" =~ '.*\.symlink$' ]]; then
debug "Loading env config: $file"
source $file
fi
done
}
function load_general_config {
debug "Loading general config files..."
local -a generals
generals=(${(f)DOTFILE_CONFIG_FILES})
generals=(${generals#*/path.zsh})
generals=(${generals#*/completion.zsh})
# generals=(${generals#*/aliases.zsh})
generals=(${generals#*/env.zsh})
for file in $generals; do
debug "Processing general config $file..."
if ! [[ "$file" =~ '.*\.symlink$' ]]; then
debug "Loading general config: $file"
source $file
fi
done
}