-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·173 lines (137 loc) · 3.91 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·173 lines (137 loc) · 3.91 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
#!/usr/bin/env bash
readonly VUNDLE_URL="https://github.com/gmarik/vundle.git"
readonly FONTS_URL="https://github.com/Lokaltog/powerline-fonts.git"
readonly GITCTAGS_URL="https://github.com/esneider/gitctags.git"
readonly HOMEBREW_URL="https://raw.github.com/Homebrew/homebrew/go/install"
silent() {
eval "(${@}) >/dev/null 2>&1"
}
exists() {
silent command -v "${1}"
}
error() {
echo "ERROR: ${1}"
exit 1
}
install() {
echo "Installing ${1}..."
if ! silent "${@:2}"; then
echo "WARNING: failed to install ${1}"
fi
}
npm_install() {
if exists npm && ! silent npm list -g "${1}"; then
install "${1}" npm install -g "${@}"
fi
}
pip_install() {
if exists pip && ! (pip show "${1}" | grep ".") >/dev/null 2>&1; then
install "${1}" pip install "${@}"
fi
}
brew_install() {
if exists brew && ! silent brew list "${1}"; then
install "${1}" brew install "${@}"
fi
}
apt_get_install() {
if ! (dpkg-query -Wf'${Status}' "${1}" | grep "^i") >/dev/null 2>&1; then
install "${1}" sudo apt-get install -y "${@}"
fi
}
setup_mac() {
if ! exists "xcode-select"; then
error "you should install Xcode from the App Store"
fi
if ! silent "xcode-select" -p; then # TODO: is this working?
install "developer tools" "xcode-select" --install
fi
if ! exists brew; then
echo "Installing homebrew..."
if ! ruby -e "$(curl -fsSL "${HOMEBREW_URL}")"; then
error "failed to install homebrew"
fi
echo 'export ARCHFLAGS="-arch x86_64"' >> ~/.bash_profile
echo 'export PATH="$(brew --prefix)/bin:${PATH}"' >> ~/.bash_profile
fi
brew_install cmake
brew_install curl
brew_install git
brew_install node
brew_install shellcheck
brew_install ctags
brew_install ag
brew_install vim
}
setup_ubuntu() {
sudo apt-get update
apt_get_install build-essential
apt_get_install cmake
apt_get_install python-dev
apt_get_install libclang-dev
apt_get_install git
apt_get_install nodejs
apt_get_install npm
apt_get_install shellcheck
apt_get_install exuberant-ctags
apt_get_install silversearcher-ag
apt_get_install vim
}
initial_setup() {
cd "$(dirname "${0}")"
if ! [ -f vimrc ]; then
error "can't find vimrc file"
fi
if ! silent ping -w 5000 -c 1 google.com &&
! silent ping -W 5000 -c 1 google.com
then
error "no internet connection"
fi
if [[ $(uname -s) == "Darwin" ]] && ! exists port; then
setup_mac
fi
if [[ $(uname -v) == *"Ubuntu"* ]]; then
setup_ubuntu
fi
if ! exists vim; then
error "you must install 'vim'"
fi
if ! exists git; then
error "you must install 'git'"
fi
}
install_vimrc() {
echo "Installing vimrc..."
silent mv -f ~/.vim ~/.vim.bak
silent mv -f ~/.vimrc ~/.vimrc.bak
mkdir ~/.vim{,/bundle,/extras,/undo}
if ! silent git clone "${VUNDLE_URL}" ~/.vim/bundle/vundle; then
silent mv -f ~/.vimrc.bak ~/.vimrc
silent mv -f ~/.vim.bak ~/.vim
error "can't connect to github"
fi
if ! silent ln vimrc ~/.vimrc; then
echo "WARNING: failed to hard-link vimrc, falling back to copy"
cp vimrc ~/.vimrc
fi
vim +PluginInstall +qall
}
final_setup() {
pip_install flake8
npm_install jshint
npm_install csslint
npm_install instant-markdown-d
cd ~/.vim/bundle/tern_for_vim
install "tern" npm install
cd ~/.vim/bundle/YouCompleteMe
install "YCM (slooow)" ./install.sh --clang-completer --tern-completer --system-libclang
cd ~/.vim/extras
install "fonts" git clone "${FONTS_URL}" fonts
install "git-ctags" git clone "${GITCTAGS_URL}" gitctags
silent ./gitctags/setup.sh
}
initial_setup
install_vimrc
final_setup
echo "Done!!!"
echo "Note: Use a font from '~/.vim/extras/fonts' to have a pretty status bar"