-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap
More file actions
executable file
·183 lines (154 loc) · 3.9 KB
/
bootstrap
File metadata and controls
executable file
·183 lines (154 loc) · 3.9 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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env bash
set -e
###
# TODO
# - Resolve conflicts between macvim and vim in brew
# - Add sshkeygen before Chezmoi
# - Ensure brew still continues even if there are conflicts with pre-installed packages
###
###
# functions
###
installed() { hash $1 &> /dev/null; }
###
# globals
###
# Determine the script path
TARGET_FILE=$0
cd "$(dirname "$TARGET_FILE")"
TARGET_FILE=$(basename "$TARGET_FILE")
# Iterate down a (possible) chain of symlinks
while [ -L "$TARGET_FILE" ]; do
TARGET_FILE=$(readlink "$TARGET_FILE")
cd "$(dirname "$TARGET_FILE")"
TARGET_FILE=$(basename "$TARGET_FILE")
done
# Put it all together
SCRIPT_PATH=$(pwd -P)/$TARGET_FILE
ROOT=$(dirname $SCRIPT_PATH)
# User input vars
BREW=false
BREW_HOME=false
BREW_MUSIC=false
BREW_FUN=false
CHEZMOI=false
VIM_SUBMODULES=false
OSX=false
###
# User input - determine what to install
###
while true; do
read -p "Install your default brew bundle packages? " yn
case $yn in
[Yy]* ) BREW=true; break;;
[Nn]* ) BREW=false; break;;
* ) echo "Please answer yes or no.";;
esac
done
while true; do
read -p "Install your home brew bundle packages? " yn
case $yn in
[Yy]* ) BREW_HOME=true; break;;
[Nn]* ) BREW_HOME=false; break;;
* ) echo "Please answer yes or no.";;
esac
done
while true; do
read -p "Install your music brew bundle packages? " yn
case $yn in
[Yy]* ) BREW_MUSIC=true; break;;
[Nn]* ) BREW_MUSIC=false; break;;
* ) echo "Please answer yes or no.";;
esac
done
while true; do
read -p "Install your fun brew bundle packages (games, media, etc)? " yn
case $yn in
[Yy]* ) BREW_FUN=true; break;;
[Nn]* ) BREW_FUN=false; break;;
* ) echo "Please answer yes or no.";;
esac
done
while true; do
read -p "Setup dotfiles with Chezmoi? " yn
case $yn in
[Yy]* ) CHEZMOI=true; break;;
[Nn]* ) CHEZMOI=false; break;;
* ) echo "Please answer yes or no.";;
esac
done
while true; do
read -p "Install vim submodules? " yn
case $yn in
[Yy]* ) VIM_SUBMODULES=true; break;;
[Nn]* ) VIM_SUBMODULES=false; break;;
* ) echo "Please answer yes or no.";;
esac
done
while true; do
read -p "Setup OSX defaults? " yn
case $yn in
[Yy]* ) OSX=true; break;;
[Nn]* ) OSX=false; break;;
* ) echo "Please answer yes or no.";;
esac
done
###
# Installer
###
# command line tools
# note: must come before brew bundle
if ! xcode-select -p 1>/dev/null; then
xcode-select --install
fi
# Homebrew
if ! installed brew; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# install everything from Brewfile
if $BREW ; then
brew bundle
fi
# install from home only Brewfile
if $BREW_HOME ; then
brew bundle --file $ROOT/Brewfile.home
fi
if $BREW_MUSIC ; then
brew bundle --file $ROOT/Brewfile.music
fi
if $BREW_FUN ; then
brew bundle --file $ROOT/Brewfile.fun
fi
# oh-my-zsh
if ! [[ -d $HOME/.oh-my-zsh ]]; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone https://github.com/reobin/typewritten.git $ZSH_CUSTOM/themes/typewritten
ln -s "$ZSH_CUSTOM/themes/typewritten/typewritten.zsh-theme" "$ZSH_CUSTOM/themes/typewritten.zsh-theme"
ln -s "$ZSH_CUSTOM/themes/typewritten/async.zsh" "$ZSH_CUSTOM/themes/async"
fi
# Chezmoi
if $CHEZMOI ; then
chezmoi init https://github.com/cknadler/dotfiles.git
chezmoi -R apply
pushd ~/.local/share/chezmoi
git remote rm origin
git remote add origin git@github.com:cknadler/dotfiles.git
git fetch
git branch -u origin/master
popd
fi
# Marta
defaults write -g NSFileViewer -string org.yanex.marta
# install vim submodules
if $VIM_SUBMODULES ; then
vim +PluginInstall +qall
fi
# vim-anywhere
if ! [[ -d $HOME/.vim-anywhere ]]; then
curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | bash
fi
# OSX defaults
# should always be run last as it will shut down Terminal
if $OSX ; then
$ROOT/.osx
fi