-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
91 lines (73 loc) · 2.3 KB
/
install.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# -*- coding: utf-8 -*-
INSTALL_DIRECTORY=$HOME/.submacs
USER_CONFIG_DIRECTORY=${INSTALL_DIRECTORY}/user-config
SYSTEM_CONFIG_DIRECTORY=${INSTALL_DIRECTORY}/system
EXECUTABLE=emacs
DOTEMACS=${HOME}/.emacs
BATCH_ARGS="-u ${USER} --batch"
REFRESH_PACKAGES="true"
function copy_submacs_files() {
cp src/*.el ${SYSTEM_CONFIG_DIRECTORY}
git clone [email protected]:subfusc/ruby-block ${SYSTEM_CONFIG_DIRECTORY}/ruby-block
mkdir -p ${USER_CONFIG_DIRECTORY}
echo ";;; Custom user mods goes here" > ${USER_CONFIG_DIRECTORY}/user-init.el
echo "(provide 'user-init)" >> ${USER_CONFIG_DIRECTORY}/user-init.el
}
function pre_install_dotemacs() {
if [ -f ${DOTEMACS} ]; then
rm $DOTEMACS
fi
mkdir -p ${SYSTEM_CONFIG_DIRECTORY}
cp src/melpa.el ${SYSTEM_CONFIG_DIRECTORY}
echo "; -*- coding: utf-8 -*-" > $DOTEMACS
echo "" >>$DOTEMACS
echo "(prefer-coding-system 'utf-8)" >>$DOTEMACS
echo '(set-language-environment "utf-8")' >>$DOTEMACS
echo "(add-to-list 'load-path \"${SYSTEM_CONFIG_DIRECTORY}\")" >>$DOTEMACS
echo "(require 'melpa)" >>$DOTEMACS
}
function add_load_paths_to_submacs() {
echo "(add-to-list 'load-path \"${SYSTEM_CONFIG_DIRECTORY}/ruby-block\")" >>$DOTEMACS
echo "(add-to-list 'load-path \"${USER_CONFIG_DIRECTORY}\")" >>$DOTEMACS
echo "(require 'submacs-init)" >>$DOTEMACS
echo "(require 'user-init)" >>$DOTEMACS
}
function install_packages() {
$EXECUTABLE $BATCH_ARGS --script install/package-install.el
}
function update_gnu_keyring() {
$EXECUTABLE $BATCH_ARGS --script install/update-keyring.el
}
function clean() {
rm -rfv ${SYSTEM_CONFIG_DIRECTORY}
rm $DOTEMACS
rm -rfv ~/.emacs.d
}
function newinstall() {
pre_install_dotemacs
update_gnu_keyring
install_packages
copy_submacs_files
add_load_paths_to_submacs
}
function reinstall() {
clean
newinstall
}
OPT=NEWINSTALL
while getopts “rc” OPTION
do
case $OPTION in
r) OPT=REINSTALL;;
c) OPT=CLEAN;;
esac
done
case $OPT in
NEWINSTALL)
newinstall;;
REINSTALL)
reinstall;;
CLEAN)
clean;;
esac