-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup
More file actions
executable file
·169 lines (134 loc) · 3.69 KB
/
Copy pathsetup
File metadata and controls
executable file
·169 lines (134 loc) · 3.69 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
#!/bin/sh
# Welcome to the Rightmove laptop script!
# This script is heavily influenced by the original Thoughbot script.
# Be prepared to turn your laptop (or desktop, no haters here)
# into an awesome development machine.
fancy_echo() {
fmt="$1"; shift
# shellcheck disable=SC2059
printf "\n$fmt\n" "$@"
}
append_to_bashrc() {
text="$1"
bashrc=""
skip_new_line="${2:-0}"
if [ -w "$HOME/.bashrc.local" ]; then
bashrc="$HOME/.bashrc.local"
else
bashrc="$HOME/.bashrc"
fi
if ! grep -Fqs "$text" "$bashrc"; then
if [ "$skip_new_line" -eq 1 ]; then
printf "%s\n" "$text" >> "$bashrc"
else
printf "\n%s\n" "$text" >> "$bashrc"
fi
fi
}
install_global_npm() {
formulae="$1"
if ! command -v formula >/dev/null; then
npm install -g "$formulae"
else
npm update -g "$formulae"
fi
}
# shellcheck disable=SC2154
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
if [ ! -d "$HOME/.bin/" ]; then
mkdir "$HOME/.bin"
fi
if [ ! -f "$HOME/.bashhrc" ]; then
touch "$HOME/.bashrc"
fi
if [ ! -f "$HOME/.bash_profile" ]; then
touch "$HOME/.bash_profile"
fi
# Load .bashrc when loading .bash_profile
command="if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi"
if ! grep -Fqs "$command" "$HOME/.bash_profile"; then
printf "%s\n" "$command" >> "$HOME/.bash_profile"
fi
# shellcheck disable=SC2016
append_to_bashrc 'export PATH="$HOME/.bin:$PATH"'
# shellcheck disable=SC2046
if [ $(defaults read com.apple.finder AppleShowAllFiles -bool) = NO ]; then
defaults write com.apple.finder AppleShowAllFiles YES
killall Finder
fi
if ! command -v gcc >/dev/null; then
fancy_echo "Installing XCode command-line tools for Homebrew ..."
xcode-select --install
fi
HOMEBREW_PREFIX="/usr/local"
if [ -d "$HOMEBREW_PREFIX" ]; then
if ! [ -r "$HOMEBREW_PREFIX" ]; then
sudo chown -R "$LOGNAME:admin" /usr/local
fi
else
sudo mkdir "$HOMEBREW_PREFIX"
sudo chflags norestricted "$HOMEBREW_PREFIX"
sudo chown -R "$LOGNAME:admin" "$HOMEBREW_PREFIX"
fi
if ! command -v brew >/dev/null; then
fancy_echo "Installing Homebrew ..."
curl -fsS \
'https://raw.githubusercontent.com/Homebrew/install/master/install' | ruby
append_to_bashrc '# recommended by brew doctor'
# shellcheck disable=SC2016
append_to_bashrc 'export PATH="/usr/local/bin:$PATH"' 1
export PATH="/usr/local/bin:$PATH"
fi
if brew list | grep -Fq brew-cask; then
fancy_echo "Uninstalling old Homebrew-Cask ..."
brew uninstall --force brew-cask
fi
fancy_echo "Updating Homebrew formulae ..."
brew update
brew bundle --file=- <<EOF
# Brew taps
tap "caskroom/cask"
tap "homebrew/completions"
# Unix
brew "bash-completion"
brew "git"
brew "openssl"
# Programming languages
cask "java"
cask "caskroom/versions/java7"
brew "gradle"
brew "node"
# Browser
cask "google-chrome"
brew "chromedriver"
brew "selenium-server-standalone"
# Applications
cask "atom"
cask "dbeaver-enterprise"
cask "docker"
cask "intellij-idea"
cask "slack"
# Bash completions
brew "docker-completion"
brew "docker-compose-completion"
brew "docker-machine-completion"
EOF
fancy_echo "Set bash completion in .bashrc"
append_to_bashrc "if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi"
fancy_echo "Installing node dependencies ..."
install_global_npm "n"
install_global_npm "gulp"
if [ -f "$HOME/.laptop.local" ]; then
fancy_echo "Running your customizations from ~/.laptop.local ..."
# shellcheck disable=SC1090
. "$HOME/.laptop.local"
else
fancy_echo "If you believe we are missing something essential, please create a PR; otherwise add it to '/.laptop.local' for local updating"
fi
rm -rf node_modules
fancy_echo "YOU ARE NOW UP-TO-DATE"