forked from vntw/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·154 lines (126 loc) · 3.14 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/env bash
set -eu
[ "$USER" = "root" ] && abort "Run this as yourself, not root."
DIR="$(cd `dirname $0` && pwd)"
cd "$DIR"
function info() {
echo -e "\n\033[0;32m➤ $1\033[0m"
}
function directories() {
info "Creating default directories…"
mkdir -p ~/bin ~/dev/go ~/.gnupg ~/.ssh
chmod 0700 ~/.gnupg ~/.ssh
}
function dotfiles() {
info "Linking dotfiles…"
for f in $(find "$DIR/home" -type f) ; do
echo "$f to ~/${f#"$DIR/home/"}"
ln -sF "$f" ~/${f#"$DIR/home/"}
done
}
function settings() {
info "Linking app settings…"
info "Skipped for now"
# ln -sF $DIR/settings/vscode/*.json ~/Library/Application\ Support/Code/User/
}
function macos() {
info "Applying macOS settings…"
./macos
}
function homebrew() {
info "Installing Brew…"
if ! type brew >/dev/null 2>/dev/null; then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
echo "Brew already installed"
return
fi;
info "Bundling Brewfile…"
brew bundle --file=./Brewfile
brew cleanup
# change shell to updated brew zsh
local shell_path="/usr/local/bin/zsh"
info "Changing shell to '$shell_path'"
if [ $SHELL != $shell_path ]; then
if ! grep "$shell_path" /etc/shells > /dev/null 2>&1 ; then
sudo sh -c "echo $shell_path >> /etc/shells"
fi
chsh -s "$shell_path"
fi
}
function zsh() {
info "Setting up zsh"
if [ -d ~/.oh-my-zsh ]; then
echo "zsh already installed"
else
git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
fi
if [ -d ~/.oh-my-zsh/custom/themes/powerlevel10k ]; then
echo "powerlevel10k already installed"
else
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k
curl -L https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/SourceCodePro/Regular/complete/Sauce%20Code%20Pro%20Nerd%20Font%20Complete.ttf -o ~/Library/Fonts/Sauce\ Code\ Pro\ Nerd\ Font\ Complete.ttf
curl -L https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/SourceCodePro/Regular/complete/Sauce%20Code%20Pro%20Nerd%20Font%20Complete%20Mono.ttf -o ~/Library/Fonts/Sauce\ Code\ Pro\ Nerd\ Font\ Complete\ Mono.ttf
fi
}
function privrepo() {
info "Installing \033[0;31mprivate\033[32m repository"
if [ ! -d ~/Dev/private/dotfiles ]; then
git clone [email protected]:koengsen/dotfiles.git ~/Dev/private/dotfiles
~/Dev/private/dotfiles/install.sh
else
echo "Repository already checked out"
fi
}
function install() {
sudo -v
privrepo;
directories;
homebrew;
dotfiles;
zsh;
settings;
macos;
success;
}
function linksonly() {
settings;
privrepo;
dotfiles;
success;
}
function success() {
info "Successfully installed!"
}
function helpmenu() {
cat << EOF
Usage: ./install.sh [--help|-h] [--only-links]
--only-links Only create symlinks for settings/public/private repo
EOF
}
while [ ! $# -eq 0 ]
do
case "$1" in
--help | -h)
helpmenu;
exit
;;
--only-links)
linksonly;
exit
;;
esac
shift
done
install;
unset success;
unset linksonly;
unset privrepo;
unset directories;
unset macos;
unset dotfiles;
unset zsh;
unset homebrew;
unset helpmenu;
unset install;
unset info;