-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·105 lines (90 loc) · 2.33 KB
/
install.sh
File metadata and controls
executable file
·105 lines (90 loc) · 2.33 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
set -euo pipefail
FRESH=0
EMACS_PROFILE="${HOME}/.emacs.d"
EMACS_PACKAGES_DIR="${EMACS_PROFILE}/packages"
EMACS_LOAD_DIR="${EMACS_PROFILE}/load"
case ${1:-""} in
-h | --help)
echo "./install.sh [--fresh] [--help]"
echo
echo " --fresh will install everything from scratch."
echo " To simply update, run without arguments."
exit 0
;;
--fresh)
FRESH=1
;;
esac
shopt -s nullglob
stow --target=$HOME/.emacs.d/ .emacs.d
if [[ $FRESH != 1 ]]; then
echo "If you want to install from scratch, run this script with --fresh parameter."
exit 0
fi
if ! which emacs; then
echo ""
read -r -p ">> Emacs is not installed, want to install it? [y/n]" choice
if [[ $choice =~ ^[Yy]$ ]]; then
case $(uname) in
Darwin*)
brew tap d12frosted/emacs-plus
brew install emacs-plus@29 \
--with-dragon-icon \
--with-dbus \
--with-no-frame-refocus \
--with-native-comp \
--with-imagemagick \
--with-poll \
--with-xwidgets
;;
Linux*)
sudo pacman -S emacs
;;
esac
else
echo "Exiting..."
exit 1
fi
fi
set +e
read -rd '' EMACS_EVAL <<EOF
(progn
(require 'org)
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(shell . t)
(python . t)
(js . t)))
(setq org-confirm-babel-evaluate nil)
(add-hook 'org-babel-post-tangle-hook 'executable-make-buffer-file-executable-if-script-p)
(defun when-darwin (file-path)
(if (eq system-type 'darwin)
(progn
(message ":: Tangling %s" file-path)
file-path)
"no"))
(defun when-linux (file-path)
(if (eq system-type 'gnu/linux)
(progn
(message ":: Tangling %s" file-path)
file-path)
"no"))
(cl-defun when-on (&key linux darwin)
(pcase system-type
('darwin
(message ":: Tangling %s" darwin)
darwin)
('gnu/linux
(message ":: Tangling %s" linux)
linux)))
(org-babel-tangle-file "./index.org"))
EOF
set -e
echo "=> Installing dotfiles..."
emacs -Q \
--batch \
--eval '(setq org-babel-noweb-wrap-start "<<<")' \
--eval '(setq org-babel-noweb-wrap-end ">>>")' \
--eval "$EMACS_EVAL"