-
Notifications
You must be signed in to change notification settings - Fork 1
/
dotf.sh
executable file
·73 lines (61 loc) · 1.23 KB
/
dotf.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
72
73
#!/bin/bash
. ./messages.sh
DF_DIR=$(pwd)
BKPDIR=~/.dotf_bkps/
WILL_UPDATE=0
args=("$@")
action="${args[0]}"
call_dotfile_script()
{
i="1"
while [[ ! -z "${args[i]// }" ]]; do
local _dotfile=${args[i]}
if [[ -d $_dotfile ]]; then
chmod u+x $_dotfile/$_dotfile'.sh'
./$_dotfile/$_dotfile'.sh' $action
fi
i=$[$i + 1]
done
}
if [[ $action == "help" ]]; then
_help_msg
else
call_dotfile_script
fi
# This functions is executed by the dotfile scripts.
# The variables that are called in the functions , and are not defined here,
# are defined in dotfile scripts, that calls the function
update()
{
if [[ $WILL_UPDATE -eq 0 ]]; then
sudo apt-get update
WILL_UPDATE=1
fi
}
manage_action()
{
local _action=$1
case $_action in
'install')
install ;;
'restore')
sample_restore ;;
esac
}
create_bkp()
{
local _bkp=$1
create_bkp_msg "$_bkp"
mkdir -p "$_bkp" > /dev/null
}
sample_restore()
{
sample_restore_msg $app
sudo rm -rf ~/."$app"/
if [[ ! -e $bkp/."$dotfile" ]]; then
rm $HOME/.$dotfile
else
mv $bkp/.$dotfile "$HOME"/
fi
mv $bkp/.$app/ "$HOME"/
}