forked from paulmillr/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·151 lines (127 loc) · 4 KB
/
bootstrap.sh
File metadata and controls
executable file
·151 lines (127 loc) · 4 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
#!/usr/bin/env zsh
#
# A script for setting up an OS X dev environment.
# Adapted from Paul Miller.
# Additionally combines concepts from Mathias, Lars Kappert and others.
#
# More about these dotfiles:
# https://github.com/bsuper/dotfiles/blob/master/README.md
#
# Learn more about dotfiles:
# - https://medium.com/@webprolific/getting-started-with-dotfiles-43c3602fd789#.6b6pzmaxn
# - https://dotfiles.github.io/
#
# ==================================================================
# = Functions =
# ==================================================================
# https://github.com/monfresh/laptop/blob/master/mac
brew_install_or_upgrade() {
if brew_is_installed "$1"; then
if brew_is_upgradable "$1"; then
echo "Upgrading %s ..." "$1"
brew upgrade "$@"
else
echo "Already using the latest version of %s. Skipping ..." "$1"
fi
else
echo "Installing %s ..." "$1"
brew install "$@"
fi
}
brew_is_installed() {
brew list -1 | grep -Fqx "$1"
}
brew_is_upgradable() {
! brew outdated --quiet "$1" >/dev/null
}
brew_tap_is_installed() {
brew tap | grep -Fqx "$1"
}
brew_tap() {
if ! brew_tap_is_installed "$1"; then
echo "Tapping $1..."
brew tap "$1" 2> /dev/null
fi
}
brew_cask_expand_alias() {
brew cask info "$1" 2>/dev/null | head -1 | awk '{gsub(/:/, ""); print $1}'
}
brew_cask_is_installed() {
local NAME
NAME=$(brew_cask_expand_alias "$1")
brew cask list -1 | grep -Fqx "$NAME"
}
app_is_installed() {
local app_name
app_name=$(echo "$1" | cut -d'-' -f1)
find /Applications -iname "$app_name*" -maxdepth 1 | egrep '.*' > /dev/null
}
brew_cask_install() {
if app_is_installed "$1" || brew_cask_is_installed "$1"; then
echo "$1 is already installed. Skipping..."
else
echo "Installing $1..."
brew cask install "$@"
fi
}
# ==================================================================
# = Configuration =
# ==================================================================
# dev="$HOME/Developer"
# pushd .
# mkdir -p $dev
# cd $dev
# Add SSH key to GitHub during installation
pub=$HOME/.ssh/id_rsa.pub
echo 'Checking for SSH key, generating one if it does not exist ...'
[[ -f $pub ]] || ssh-keygen -t rsa
echo 'Copying public key to clipboard. Paste it into your Github account ...'
[[ -f $pub ]] && cat $pub | pbcopy
open 'https://github.com/account/ssh'
# If we're on OS X, install Homebrew and tweak the system a bit
if [[ `uname` == 'Darwin' ]]; then
# Install Homebrew
if ! command -v brew >/dev/null; then
echo "Installing Homebrew ..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
echo "Homebrew already installed. Skipping ..."
fi
# Update Homebrew formulas
echo "Updating Homebrew formulas ..."
brew update
# Install formulas
brew_install_or_upgrade cmake
brew_install_or_upgrade ctags
brew_install_or_upgrade git
brew_install_or_upgrade htop
brew_install_or_upgrade python@2
brew linkapps python
brew_install_or_upgrade the_silver_searcher
brew_install_or_upgrade tmux
brew_install_or_upgrade trash
brew_install_or_upgrade tree
brew_install_or_upgrade vim
brew_install_or_upgrade wget
# Install additional apps
echo 'Installing OS X apps ...'
brew_cask_install adobe-creative-cloud
brew_cask_install caffeine
brew_cask_install controlplane
brew_cask_install flux
brew_cask_install google-chrome
brew_cask_install iterm2
brew_cask_install numi
brew_cask_install spotify
brew_cask_install sublime-text
fi
# Stupid homebrew update breaks traditional method of installing python.
# https://github.com/Homebrew/homebrew-core/issues/15746
export PATH="$(brew --prefix)/opt/python/libexec/bin:$PATH"
echo 'export PATH="$(brew --prefix)/opt/python/libexec/bin:$PATH"' >> ~/.zshrc
# Virtualenv
pip install --upgrade pip
pip install virtualenv numpy pandas seaborn jupyter scipy sklearn yapf matplotlib ipywidgets
# ublock origin
open https://www.ublock.org/newdl/safari/0.9.5.2
echo 'Completed bootstrap.sh'