-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·51 lines (43 loc) · 1.13 KB
/
setup.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
#!/bin/bash
cd "$(dirname "${BASH_SOURCE}")"
CONFIG_LOCATION=`pwd`
echo $CONFIG_LOCATION
# Update git repository to the most up to date
update_git() {
git pull origin master
git_exit_code=$?
if [[ $git_exit_code != 0 ]]; then
exit $git_exit_code
fi
}
# Clean git if we want
ask_clean_git() {
git clean -nx
read -p "Clean the above files? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
git clean -fx
fi
}
# Symlink .emacs.d directory to user home
link_emacs_d() {
# Remove old symlink if it exists and replace.
# We can't use ln -sfT ... because MacOS ln does not support it!
rm -rf "$HOME/.emacs.d"
ln -s "$CONFIG_LOCATION/.emacs.d" "$HOME/.emacs.d"
}
# Prepare repository
update_git
ask_clean_git
# Clone and build C/C++/Obj-C language server if not present, otherwise update.
./setup_ccls.sh
# If -f option is provided, just get it over with
if [ "$1" == "--force" -o "$1" == "-f" ]; then
link_emacs_d
else
read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
link_emacs_d
fi
fi