forked from pathikrit/mac-setup-script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
138 lines (122 loc) · 2.77 KB
/
Copy pathsetup.sh
File metadata and controls
138 lines (122 loc) · 2.77 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
#!/usr/bin/env bash
brews=(
cask
m-cli
mackup
mas
ruby
wget
)
casks=(
atom
balenaetcher
cyberduck
dropbox
evernote
google-chrome
istat-menus
postman
spectacle
spotify
vlc
)
apms=(
atom-beautify
atom-bootstrap3
atom-html-preview
auto-update-packages
compare-files
config-import-export
copy-as-rtf
editorconfig
filesize
highlight-selected
hyperclick
js-hyperclick
language-docker
linter
linter-eslint
minimap
script
terminal-plus
tool-bar
tool-bar-almighty
)
######################################## End of app list ########################################
set +e
set -x
function prompt {
if [[ -z "${CI}" ]]; then
read -p "Hit Enter to $1 ..."
fi
}
function install {
cmd=$1
shift
for pkg in "$@";
do
exec="$cmd $pkg"
#prompt "Execute: $exec"
if ${exec} ; then
echo "Installed $pkg"
else
echo "Failed to execute: $exec"
if [[ ! -z "${CI}" ]]; then
exit 1
fi
fi
done
}
function brew_install_or_upgrade {
if brew ls --versions "$1" >/dev/null; then
if (brew outdated | grep "$1" > /dev/null); then
echo "Upgrading already installed package $1 ..."
brew upgrade "$1"
else
echo "Latest $1 is already installed"
fi
else
brew install "$1"
fi
}
if [[ -z "${CI}" ]]; then
sudo -v # Ask for the administrator password upfront
# Keep-alive: update existing `sudo` time stamp until script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
fi
if test ! "$(command -v brew)"; then
prompt "Install Homebrew"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
if [[ -z "${CI}" ]]; then
prompt "Update Homebrew"
brew update
brew upgrade
brew doctor
fi
fi
export HOMEBREW_NO_AUTO_UPDATE=1
echo "Install software ..."
brew tap caskroom/versions
install 'brew cask install' "${casks[@]}"
prompt "Install packages"
install 'brew_install_or_upgrade' "${brews[@]}"
brew link --overwrite ruby
prompt "Upgrade bash"
brew install bash bash-completion2 fzf
sudo bash -c "echo $(brew --prefix)/bin/bash >> /private/etc/shells"
#sudo chsh -s "$(brew --prefix)"/bin/bash
# Install https://github.com/twolfson/sexy-bash-prompt
touch ~/.bash_profile #see https://github.com/twolfson/sexy-bash-prompt/issues/51
(cd /tmp && git clone --depth 1 --config core.autocrlf=false https://github.com/twolfson/sexy-bash-prompt && cd sexy-bash-prompt && make install) && source ~/.bashrc
prompt "Install secondary packages"
install 'apm install' ${apms[@]}
if [[ -z "${CI}" ]]; then
prompt "Install software from App Store"
mas list
fi
prompt "Cleanup"
brew cleanup
brew cask cleanup
echo "Run [mackup restore] after DropBox has done syncing ..."
echo "Done!"