-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-script.sh
executable file
·136 lines (117 loc) · 4.13 KB
/
setup-script.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
#!/bin/bash
# detect os
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
echo "Running $1 on ${machine}"
function not_implemented {
echo "not implemented"
exit
}
function help_impl {
echo "usage: $0 help|zsh|ycm|vim|bootstrap|all"
exit
}
function emacs_impl
{
case "${machine}" in
Linux) sudo apt-get install emacs;;
Mac) brew install emacs;;
*) not_implemented
esac
git clone https://github.com/hlissner/doom-emacs ~/.emacs.d
~/.emacs.d/bin/doom install
}
# check if brew is installed on mac
function bootstrap_impl {
case "${machine}" in
Linux) sudo apt-get install git;;
Mac) /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" && brew install git;;
*) not_implemented
esac
mv $0 ~/
cd ~/
rm -r configs
git clone --recurse-submodule https://github.com/Tschet1/configs.git
mv configs/.[a-zA-Z]* ~/
}
function vim_impl {
case "${machine}" in
Linux) sudo apt-get install neovim python3 fzf ripgrep;;
Mac) brew install nvim python3 fzf ripgrep;;
*) not_implemented
esac
ln -s /usr/opt/local/bin/nvim /usr/opt/local/bin/vim
python3 -m pip install --user --upgrade pynvim
vim +PluginInstall +qall
}
function zsh_impl {
case "${machine}" in
Linux) sudo apt-get install git zsh tmux;;
Mac) brew install git zsh tmux;;
*) not_implemented
esac
chsh -s /bin/zsh || exit
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
if [[ "${machine}" == "Mac" ]]; then
compaudit | xargs chmod g-w,o-w
fi
if [[ "${machine}" == "Linux" ]]; then
apt install xclip
alias pbcopy='xclip -sel clip'
fi
}
function ycm_impl {
case "${machine}" in
Linux) sudo apt install curl python3-dev git zsh vim ctags cmake npm yarn python3;;
Mac) brew install git zsh vim ctags cmake npm yarn python3;;
*) not_implemented
esac
# install rust
if ! which rustup > /dev/null; then
curl https://sh.rustup.rs -sSf | sh
export PATH="$PATH:~/.cargo/bin"
fi
mkdir ~/.zfunc
rustup completions zsh > ~/.zfunc/_rustup
# install you complete me
cd ~
mkdir ycm_build
cd ycm_build
if [[ "${machine}" == "Mac" ]]; then
cmake -DPYTHON_LIBRARY=/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7.dylib -DPYTHON_INCLUDE_DIR=/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m -G "Unix Makefiles" -DUSE_SYSTEM_LIBCLANG=ON -DUSE_PYTHON2=off . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
else
cmake -G "Unix Makefiles" -DUSE_PYTHON2=off . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
fi
cmake --build . --target ycm_core --config Release
cd ~
mkdir regex_build
cd regex_build
if [[ "${machine}" == "Mac" ]]; then
cmake -DPYTHON_LIBRARY=/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7.dylib -DPYTHON_INCLUDE_DIR=/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex
else
cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex
fi
cmake --build . --target _regex --config Release
# add js support
npm install -g typescript
# add rust support
rustup component add rust-src
cd ~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/racerd
cargo build --release
cd ~
}
case "$1" in
help|-h|--help) help_impl;;
zsh|-z|--zsh) zsh_impl;;
ycm|-y|--ycm) ycm_impl;;
vim|-v|--vim) vim_impl;;
bootstrap|-b|--bootstrap) bootstrap_impl;;
all|-a|--all) bootstrap_impl && zsh_impl && vim_impl && ycm_impl;;
*) help_impl
esac