-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·195 lines (138 loc) · 4.49 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·195 lines (138 loc) · 4.49 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/bash
set -xe
MODE="$1"
function install {
from="$1"
to="$2"
if [ -f "$to" ]; then
cp "$to" "$to.backup-setup-env"
fi
cp -f "$from" "$to"
}
echo "*** os version ***"
cat /etc/os-release
echo "*** install packages ***"
IS_FEDORA=$(cat /etc/os-release | grep -ic fedora)
if [[ "$IS_FEDORA" != "0" ]]; then
TOOLS_PKG="tmux vim git make jq"
GO_PKG="golang"
CPP_PKG="g++ clang valgrind gdb ctags"
JAVA_PKG="java-11-openjdk" # youcompleteme wants it.
PY_PKG="python3 pylint"
NET_PKG="openssh openssh-clients curl wget strace nmap tcpdump"
OTHER_PKG="ShellCheck"
sudo dnf -y update
sudo dnf -y install $TOOLS_PKG $GO_PKG $CPP_PKG $PY_PKG $NET_PKG $OTHER_PKG $JAVA_PKG
if [[ "$MODE" != "docker" ]]; then
sudo dnf -y xsel
fi
else
IS_UBUNTU=$(cat /etc/os-release | grep -ic ubuntu)
if [[ "$IS_UBUNTU" != "0" ]]; then
VER=$(go version | sed -n 's/go version go\([^[:space:]]*\).*$/\1/p')
MAJOR_VER=""
MINOR_VER=""
if [ "$VER" != "" ]; then
MAJOR_VER=$(echo "$VER" | sed -n 's/\([[:digit:]]\+\)\.\([[:digit:]]\+\).*$/\1/p')
MINOR_VER=$(echo "$VER" | sed -n 's/\([[:digit:]]\+\)\.\([[:digit:]]\+\).*$/\2/p')
fi
# require at least 1.13
if [[ $MAJOR_VER -gt 1 ]] || [[ $MINOR_VER -ge 13 ]]; then
echo "have at least golang 1.13"
else
if [[ -z SKIP_GO_INSTALL ]]; then
# no package for golang on ubuntu right now
sudo apt-get install -qy wget
wget https://dl.google.com/go/go1.13.linux-amd64.tar.gz -O go.tar.gz
sha256sum go.tar.gz
sudo tar -C /usr/local/ -xvzf go.tar.gz
rm -rf go.tar.gz
for f in $(ls /usr/local/go/bin/); do
sudo ln -s /usr/local/go/bin/$f /usr/bin/$f
done
go version
else
echo "skipping installation of go"
fi
fi
TOOLS_PKG="tmux vim git make jq"
GO_PKG="" #golang-1.13"
CPP_PKG="g++ clang valgrind gdb exuberant-ctags clang-format"
PY_PKG="python3 pylint"
NET_PKG="openssh-client curl wget strace nmap tcpdump"
OTHER_PKG="shellcheck"
sudo apt-get -qy update
sudo apt-get install -qy $TOOLS_PKG $GO_PKG $CPP_PKG $PY_PKG $NET_PKG $OTHER_PKG
else
echo "sorry, your OS/distribution is not supported. Right now it does fedora or ubuntu"
exit 1
fi
if [[ "$MODE" != "docker" ]]; then
sudo apt-get install -qy xsel
fi
fi
if [[ -z SKIP_GO_INSTALL ]]; then
pushd $GOPATH
go get -u github.com/jstemmer/gotags
cd src/github.com/jstemmer/gotags
go build
sudo cp gotags /usr/bin
popd
fi
echo "*** setup tmux continuous save/restore ***"
if [[ ! -d ~/.tmux/plugins/tpm ]]; then
# setup stuff (probably a better way to do that)
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
if [[ ! -d ~/.tmux/plugins/tmux-resurrect ]]; then
git clone https://github.com/tmux-plugins/tmux-resurrect ~/.tmux/plugins/tmux-resurrect
fi
if [[ ! -d ~/.tmux/plugins/tmux-continuum ]]; then
git clone https://github.com/tmux-plugins/tmux-continuum ~/.tmux/plugins/tmux-continuum
fi
# write some clang-format ini file.
clang-format -style=llvm -dump-config > ~/.clang-format
if [[ "$MODE" != "docker" ]]; then
install .tmux.conf ~/.tmux.conf
install .bashrc ~/.bashrc
install .vimrc ~/.vimrc
bash -c "install -d ~/scripts"
for l in $(ls scripts/*); do
install $l ~/scripts
done
cat <<EOF
*** tmux save/restore ***
in tmux
echo "*** setup environment completed ***"
Ctl+b I : reload tmux env (first time)
Ctrl+b Ctl+s : save
Ctl+b Ctl+r : restore
*** setup environment completed ***
EOF
fi
# install buffer gator (fast buffer switching)
git clone https://github.com/jeetsukumaran/vim-buffergator ~/.vim-bf
cp -rf ~/.vim-bf/autoload/ ~/.vim
cp -rf ~/.vim-bf/plugin/ ~/.vim
rm -rf ~/.vim-bf
# install the youcompleteme plugin/vundle/etc.
# get vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
ls ~/.vim/bundle/Vundle.vim
# required stuff
if [[ "$IS_FEDORA" != "0" ]]; then
sudo dnf -y install cmake gcc-c++ make python3-devel nodejs
else
if [[ "$IS_UBUNTU" != "0" ]]; then
sudo apt-get install -qy build-essential cmake python3-dev nodejs
echo "install npm"
curl -L https://npmjs.org/install.sh | sudo sh
fi
fi
vim --version
vim +PluginInstall +qall
#vim -c MyPInstall
# build completion server
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --all
echo "*** everything set up ***"