-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstall.sh
executable file
·132 lines (106 loc) · 2.87 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
#
# © 2023 Joey Smalen
#
# Command usage:
# ./Install.sh
# ./Install.sh --server
#
# Installation of dotfiles and recommendations of dependencies.
#
declare -i linked_file_count=0
declare server="\"${1:-false}\" == \"--server\""
if [ $server ]; then
echo "Installing server-based configuration..."
fi
install() {
filename="$(basename "$1")"
directory="$(dirname "$1")"
target="$([ -z $2 ] && echo $filename || echo $2)"
if [ -e "$directory/$target" ]; then
echo "File $filename ignored because $target already exists in $directory"
return 1
fi
if [ ! -d "$directory" ]; then
mkdir -p "$directory"
echo "Intermediate directory $directory created"
fi
ln -s "$(pwd)/$filename" "$directory/$target"
if [ $? -eq 0 ]; then
linked_file_count+=1
echo "Symlinked $target to $directory"
fi
}
dependency() {
if [ ! $(which $2 2> /dev/null) ]; then
echo "Caveat: $1 may require executable $2, but it's not in PATH"
fi
}
download() {
directory="$1"
url="$2"
unpack="$3"
if [ -d "$directory" ]; then
echo "Download $directory ignored because directory already exists"
return 1
fi
mkdir -p "$directory"
echo "Downloading $url to $directory..."
cd "$directory"
curl -q "$url" | tar -xf- -C . || exit 1
if [ ! -z "$unpack" ]; then
mv $unpack/* . || exit 1
rm -r $unpack || exit 1
fi
echo "Installed content in $directory"
linked_file_count+=1
}
mkdir -p ~/.cache
install ~/.ackrc
install ~/.gitconfig
install ~/.vim/colors/default-dark.vim
install ~/.vimrc
if [ ! $server ]; then
install ~/.gitignore
install ~/.gittemplate/hooks/commit-msg
install ~/.gnupg/gpg.conf
install ~/.latexmkrc
install ~/.vim/snippet/all.snippets
install ~/.vim/snippet/tex.snippets
install ~/.vim/snippet/zig.snippets
chmod 700 ~/.gnupg
fi
dependency vim vim
dependency git git
if [ $(uname) == "Linux" ]; then
# Debian: default bashrc loads bash_aliases, use bash_local for locals
install ~/.bash_profile .bash_aliases
if [ ! $server ]; then
# *: bash_profile is loaded on login shell
install ~/.profile .bash_profile
install ~/.xinitrc
dependency xorg startx
dependency xorg xclip
dependency xorg dwm
fi
else
install ~/.bash_profile
fi
dependency vim ack
dependency vim curl
dependency vim node
dependency vim python3
if [ ! $server ]; then
dependency bash fzf
dependency bash gs
dependency bash pandoc
dependency git gpg
dependency vim ctags
dependency vim docker
dependency vim latexmk
dependency vim xpdf
fi
if [ ! $server ]; then
download ~/.vim/thesaurus "https://www.openoffice.org/lingucomponent/MyThes-1.zip" "MyThes-1.0"
fi
echo "Installed a total of $linked_file_count configuration files"