aboutsummaryrefslogtreecommitdiffstats
path: root/install.sh
blob: 67bb022d0a77b250f5b425128185719b5ea51abe (plain) (blame)
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/sh

readonly VIM_PLUGS="$HOME/.vim/pack/plugins/start"

# Clones a Git repository into $VIM_REPO_DIR if the repository does not already
# exist there.
#
# $1: Repository URL
# $2 (optional): Branch
clone_plugin() {
	path="${VIM_REPO_DIR}/$(basename "$1")"

	if [ -d "$path" ]; then
		return
	fi

	if [ -n "$2" ]; then
		git clone -b "$2" "$1" "$path"
	else
		git clone "$1" "$path"
	fi

	ln -s "$path" "$VIM_PLUGS"
}

mkdir -p "$HOME"/tmp
mkdir -p "$HOME"/.cache

rm -f "$HOME"/.bash_profile

find "$PWD" -maxdepth 1 \
	-name '.*' \
	-not -name .git \
	-not -name .DS_Store \
	-not -name .gitignore \
	-exec ln -sf {} "$HOME" \;

if [ "$(uname)" = FreeBSD ]; then
	rm "$HOME"/.editrc
	ln -sf "$PWD"/freebsd/.editrc "$HOME"
fi

# When using a separate case-sensitive volume for src on Mac, we need to put
# a copy of .editorconfig at the root of that filesystem.
#
if [ "$(uname)" = Darwin ]; then
	ln -sf "$PWD"/.editorconfig /Volumes/src/.editorconfig
fi

if [ "$(uname)" = Linux ]; then
	ln -sf "$HOME"/.profile "$HOME"/.bash_profile;
	ln -sf "$HOME"/.shrc "$HOME"/.bashrc;
fi

if command -v vim >/dev/null; then
	mkdir -p "$VIM_REPO_DIR" "$VIM_PLUGS"
	clone_plugin https://git.linskey.org/ale/
	clone_plugin https://git.linskey.org/ctrlp.vim/
	clone_plugin https://git.linskey.org/halation.vim/

	# Regenerate Vim help tags.
	vim -e -s -u NONE -c 'helptags ALL' -c q;
fi