forked from croaky/laptop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaptop.sh
executable file
·183 lines (151 loc) · 4.22 KB
/
laptop.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
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
#!/bin/bash
# This script can be run safely multiple times.
# It's tested on macOS High Sierra (10.13). It:
# - installs, upgrades, or skips system packages
# - creates or updates symlinks from `$OK/dotfiles` to `$HOME`
# - installs or updates programming languages such as Ruby, Node, and Go
set -ex
HOMEBREW_PREFIX="/usr/local"
if [ -d "$HOMEBREW_PREFIX" ]; then
if ! [ -r "$HOMEBREW_PREFIX" ]; then
sudo chown -R "$LOGNAME:admin" "$HOMEBREW_PREFIX"
fi
else
sudo mkdir "$HOMEBREW_PREFIX"
sudo chflags norestricted "$HOMEBREW_PREFIX"
sudo chown -R "$LOGNAME:admin" "$HOMEBREW_PREFIX"
fi
update_shell() {
local shell_path;
shell_path="$(which zsh)"
if ! grep "$shell_path" /etc/shells > /dev/null 2>&1 ; then
sudo sh -c "echo $shell_path >> /etc/shells"
fi
chsh -s "$shell_path"
}
case "$SHELL" in
*/zsh)
if [ "$(which zsh)" != "$HOMEBREW_PREFIX/bin/zsh" ] ; then
update_shell
fi
;;
*)
update_shell
;;
esac
if ! command -v brew >/dev/null; then
curl -fsS \
'https://raw.githubusercontent.com/Homebrew/install/master/install' | ruby
export PATH="/usr/local/bin:$PATH"
fi
brew update
brew bundle --file=- <<EOF
tap "homebrew/services"
tap "universal-ctags/universal-ctags"
tap "wata727/tflint"
brew "awscli"
brew "fzf"
brew "git"
brew "heroku"
brew "hub"
brew "imagemagick"
brew "jq"
brew "libyaml"
brew "openssl"
brew "postgresql", restart_service: :changed
brew "protobuf"
brew "reattach-to-user-namespace"
brew "redis", restart_service: :changed
brew "shellcheck"
brew "tflint"
brew "the_silver_searcher"
brew "tmux"
brew "universal-ctags", args: ["HEAD"]
brew "vim", args: ["without-ruby"]
brew "watch"
brew "watchman"
brew "yarn"
brew "zsh"
cask "aws-vault"
cask "expo-xde"
cask "kap"
cask "ngrok"
EOF
brew upgrade
brew cleanup
(
cd dotfiles
ln -sf "$PWD/asdf/asdfrc" "$HOME/.asdfrc"
ln -sf "$PWD/asdf/tool-versions" "$HOME/.tool-versions"
ln -sf "$PWD/editor/vimrc" "$HOME/.vimrc"
mkdir -p "$HOME/.vim/ftdetect"
mkdir -p "$HOME/.vim/ftplugin"
(
cd editor/vim
for f in {ftdetect,ftplugin}/*; do
ln -sf "$PWD/$f" "$HOME/.vim/$f"
done
)
mkdir -p "$HOME/.git_template/hooks"
(
cd git/git_template
for f in hooks/*; do
ln -sf "$PWD/$f" "$HOME/.git_template/$f"
done
)
ln -sf "$PWD/git/gitconfig" "$HOME/.gitconfig"
ln -sf "$PWD/git/gitignore" "$HOME/.gitignore"
ln -sf "$PWD/git/gitmessage" "$HOME/.gitmessage"
mkdir -p "$HOME/.bundle"
ln -sf "$PWD/ruby/bundle/config" "$HOME/.bundle/config"
ln -sf "$PWD/ruby/gemrc" "$HOME/.gemrc"
ln -sf "$PWD/ruby/rspec" "$HOME/.rspec"
ln -sf "$PWD/search/ctags" "$HOME/.ctags"
ln -sf "$PWD/shell/curlrc" "$HOME/.curlrc"
ln -sf "$PWD/shell/hushlogin" "$HOME/.hushlogin"
mkdir -p "$HOME/.ssh"
ln -sf "$PWD/shell/ssh" "$HOME/.ssh/config"
ln -sf "$PWD/shell/tmux.conf" "$HOME/.tmux.conf"
ln -sf "$PWD/shell/zshrc" "$HOME/.zshrc"
ln -sf "$PWD/sql/psqlrc" "$HOME/.psqlrc"
)
if [ -e "$HOME/.vim/autoload/plug.vim" ]; then
vim -u "$HOME/.vimrc" +PlugUpgrade +qa
else
curl -fLo "$HOME/.vim/autoload/plug.vim" --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
vim -u "$HOME/.vimrc" +PlugUpdate +PlugClean! +qa
if ! command -v go >/dev/null; then
if ! go version | grep -Fq "1.10.3"; then
curl https://dl.google.com/go/go1.10.3.darwin-amd64.tar.gz | sudo tar xz -C /usr/local
fi
fi
if [ -d "$HOME/.asdf" ]; then
(
cd "$HOME/.asdf"
git fetch origin
git reset --hard origin/master
)
else
git clone https://github.com/asdf-vm/asdf.git "$HOME/.asdf"
fi
asdf_plugin_update() {
if ! asdf plugin-list | grep -Fq "$1"; then
asdf plugin-add "$1" "$2"
fi
asdf plugin-update "$1"
}
asdf_plugin_update "java" "https://github.com/skotchpine/asdf-java"
asdf install java 8.172
asdf install java 10.0.1
asdf_plugin_update "maven" "https://github.com/skotchpine/asdf-maven"
asdf install maven 3.3.9
asdf_plugin_update "nodejs" "https://github.com/asdf-vm/asdf-nodejs"
export NODEJS_CHECK_SIGNATURES=no
asdf install nodejs 8.9.0
asdf_plugin_update "python" "https://github.com/tuvistavie/asdf-python.git"
asdf install python 3.6.5
asdf_plugin_update "ruby" "https://github.com/asdf-vm/asdf-ruby"
asdf install ruby 2.4.2
asdf install ruby 2.5.1