-
Notifications
You must be signed in to change notification settings - Fork 0
/
dots
executable file
·63 lines (50 loc) · 1.01 KB
/
dots
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
#!/bin/bash
declare -a enable_functions
declare -a disable_functions
install_link() {
local _TARGET=$1
local _INSTALL=$2
if [[ "$(readlink $_INSTALL)" == "$_TARGET" ]] ; then
echo "'$_INSTALL' already installed"
fi
if [[ -e "$_INSTALL" ]] ; then
mv "$_INSTALL" "${_INSTALL}.dotbak"
fi
ln -s "$_TARGET" "$_INSTALL"
}
uninstall_link() {
local _TARGET=$1
local UNINSTALL=$2
if [[ "$(readlink $UNINSTALL)" == "$_TARGET" ]] ; then
rm "$UNINSTALL"
fi
if [[ -e "${UNINSTALL}.dotbak" ]] ; then
mv "${UNINSTALL}.dotbak" "${UNINSTALL}"
fi
}
enable_all() {
for _func in ${enable_functions[@]} ; do
$_func
done
}
disable_all() {
for _func in ${disable_functions[@]} ; do
$_func
done
}
print_help() {
echo "Enable or disable dotfile configs"
echo
echo "Usage: ~/.dotfiles/dots [on|off]"
}
for _module in $HOME/.dotfiles/*/dotconf ; do
if [[ -e $_module ]] ; then
echo "Enabling: $_module"
source $_module
fi
done
case $1 in
on) enable_all ;;
off) disable_all ;;
*) print_help ;;
esac