-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit_everything.sh
executable file
·216 lines (202 loc) · 6.66 KB
/
init_everything.sh
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/usr/bin/env bash
shopt -s expand_aliases
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [ $("uname") == "Darwin" ]
then
export PATH=/opt/homebrew/bin:$PATH
if ! command -v brew &> /dev/null
then
echo "Homebrew not installed. Installing..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
echo "Updating XCode command line tools"
softwareupdate --all --install --force
fi
alias package_install="brew install"
alias YARN="yarn"
export BASHRC=$HOME/.bash_profile
touch BASHRC
else
alias package_install="sudo apt-get -y install"
alias YARN="yarnpkg"
export BASHRC=$HOME/.bashrc
fi
if [ $(version $BASH_VERSION) -lt $(version 5.0.0) ]; then
echo "Must have bash version of 5.0.0+."
package_install bash
grep -qxF $(command -v bash&) /etc/shells || echo $(command -v bash&) | sudo tee -a /etc/shells
chsh -s $(command -v bash&)
sudo chsh -s $(command -v bash&)
echo "NOTE: Bash 5.0+ installed. Restart this script in a new shell to continue."
exit 1
fi
declare -A packages_needed
# We install these packages if they are not already installed.
# `packages_needed` is a map of binary to package name in reverse order.
packages_needed['perl']='perl'
packages_needed['sqlite3']='sqlite3'
packages_needed['tmux']='tmux'
packages_needed['gcc']='gcc'
packages_needed['cscope']='cscope'
packages_needed['python3']='python3'
packages_needed['rustc']='rustc'
packages_needed['git']='git'
packages_needed['nvim']='neovim'
packages_needed['rg']='ripgrep'
packages_needed['ack']='ack'
packages_needed['npm']='npm'
packages_needed['wget']='wget'
packages_needed['curl']='curl'
packages_needed['fzf']='fzf'
if [ $("uname") == "Darwin" ]
then
packages_needed['ruby']='ruby'
packages_needed['lua']='lua'
packages_needed['ag']='ag'
packages_needed['yarn']='yarn'
packages_needed['ctags']='ctags'
packages_needed['go']='go'
else
packages_needed['go']='golang-go'
packages_needed['ruby']='ruby-dev'
packages_needed['pip3']='python3-pip'
packages_needed['lua']='lua5.3'
packages_needed['ag']='silversearcher-ag'
packages_needed['yarnpkg']='yarnpkg'
packages_needed['ctags']='exuberant-ctags'
fi
for key in "${!packages_needed[@]}"; do
bin=$key
package=${packages_needed[$key]}
if ! command -v $bin &> /dev/null
then
echo "Installing $package..."
package_install $package
fi
done
if ! command -v pipx &> /dev/null
then
if [ $("uname") == "Darwin" ]
then
brew install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
else
sudo apt update
sudo apt install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
fi
fi
if ! command -v solc &> /dev/null
then
if [ $("uname") == "Darwin" ]
then
brew tap ethereum/ethereum
brew install solidity
else
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get -y update
sudo apt-get -y install solc
fi
fi
if ! command -v gh &> /dev/null
then
if [ $("uname") == "Darwin" ]
then
brew install gh
brew install git bash-completion
else
sudo apt-get install gh
fi
echo "Authenticating Github. Login to Github..."
gh auth login
fi
if ! command -v node &> /dev/null
then
echo "Installing Node JS through NVM"
if [ $("uname") == "Darwin" ]
then
package_install nvm
else
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source $BASHRC
fi
nvm install --lts
nvm use --lts
nvm alias default lts/*
fi
if ! command -v fzf &> /dev/null
then
package_install nvm
echo "Setting up FZF to work on the command line"
if [ $("uname") == "Darwin" ]
then
$(brew --prefix)/opt/fzf/install
fi
fi
declare -A pip_packages_needed
# We install these packages if they are not already installed.
# `pip_packages_needed` is a map of binary to package name in reverse order.
if [ $("uname") == "Darwin" ]
then
pip_packages_needed['numpy']='numpy'
pip_packages_needed['matplotlib']='python-matplotlib'
pip_packages_needed['scipy']='scipy'
else
pip_packages_needed['numpy']='python3-numpy'
pip_packages_needed['matplotlib']='python3-matplotlib'
# pip_packages_needed['scipy']='python3-scipy'
pip_packages_needed['scikit-learn']='python3-sklearn python3-sklearn-lib python-sklearn-doc'
fi
for key in "${!pip_packages_needed[@]}"; do
py_package=$key
package=${pip_packages_needed[$key]}
pip_out=`pip3 list | grep "$key"`
if [ -z "$pip_out" ]; then
echo "Installing Python's $package..."
package_install $package
fi
done
if [ ! -d "$HOME/src/configs" ]; then
echo "Installing ~/src directory and configs repo"
mkdir -p $HOME/src
git clone https://github.com/mkayyash/configs.git $HOME/src/configs
fi
grep -qxF "source ~/src/configs/general_bashrc.sh" $BASHRC || echo "source ~/src/configs/general_bashrc.sh" | sudo tee -a $BASHRC
source $BASHRC
ln -s $HOME/src/configs/tmux.conf $HOME/.tmux.conf 2>/dev/null
# Check is not super robust so may need to comment the if statement out and just
# run this code anyways.
if ! grep -q "source ~/.vimrc" "$HOME/.config/nvim/init.vim"; then
if [ ! -f "$HOME/.vimrc" ]; then
ln -s $HOME/src/configs/vimrc $HOME/.vimrc 2>/dev/null
else
grep -qxF "source ~/src/configs/vimrc" $HOME/.vimrc || echo "source ~/src/configs/vimrc" | sudo tee -a $HOME/.vimrc
fi
mkdir -p $HOME/.config/nvim
touch $HOME/.config/nvim/init.vim
echo 'set runtimepath^=~/.vim runtimepath+=~/.vim/after' > $HOME/.config/nvim/init.vim
echo 'let &packpath = &runtimepath' >> $HOME/.config/nvim/init.vim
echo 'source ~/.vimrc' >> $HOME/.config/nvim/init.vim
pip3 install --user --upgrade neovim
pip3 install --user --upgrade neovim-remote
sudo gem install neovim
sudo npm install -g neovim
fi
# Check is not super robust so may need to comment the if statement out and just
# run this code anyways.
if [ ! -d "$HOME/.config/nvim/pack/minpac/opt/minpac" ]; then
export PATH="$HOME/Library/Python/3.x/bin:$PATH"
mkdir -p $HOME/.config/nvim/pack/minpac/opt
git clone https://github.com/k-takata/minpac.git $HOME/.config/nvim/pack/minpac/opt/minpac
# TODO(mkayyash): Check the output directory $HOME/.vim/ for installed packages
# to decide if we should run this minpac install (more robust).
nvim -c ":call minpac#update('', {'do': 'quitall'})"
cd $HOME/.vim/pack/minpac/start/coc.nvim/
npm i --save esbuild
YARN install && YARN build
nvim -c 'CocUpdateSync|quitall'
ln -s $HOME/src/configs/coc-settings.json $HOME/.config/nvim/ 2>/dev/null
mkdir -p $HOME/.config/clangd
ln -s $HOME/src/configs/clangd_config.yaml $HOME/.config/clangd/config.yaml 2>/dev/null
fi