-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_functions.sh
147 lines (133 loc) · 4.08 KB
/
install_functions.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
#!/bin/sh
function __install_pkg() {
distro=$(grep ^ID= /usr/lib/os-release | cut -d= -f2)
PKG_MANAGER=""
case $distro in
fedora)
PKG_MANAGER=dnf;;
raspbian)
PKG_MANAGER=apt;;
ubuntu)
PKG_MANAGER=apt;;
*)
echo >&2 "Error: could not install curl for ${distro}"
exit 1;;
esac
sudo -E ${PKG_MANAGER} install -y "$@"
unset distro
unset PKG_MANAGER
}
function __install_cargo_pkg() {
command -v cargo >/dev/null 2>&1 || { echo >&2 "Install cargo (rust) to continue"; exit 1; }
cargo install "$@"
}
function install_curl() {
command -v curl > /dev/null 2>&1 && return
__install_pkg curl
}
function install_stow() {
command -v stow > /dev/null 2>&1 && return
__install_pkg stow
}
function install_rust_analyzer() {
# skip install if clangd is installed
command -v rust-analyzer > /dev/null 2>&1 && return
command -v rustup >/dev/null 2>&1 || { echo >&2 "Install rustup (rust) to continue"; exit 1; }
rustup +nightly component add rust-analyzer-preview
# create a symlink to it to a discoverable directory in $PATH
ln -s ${HOME}/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rust-analyzer ${HOME}/.cargo/bin/rust-analyzer
}
function install_clangd() {
# skip install if clangd is installed
command -v clangd > /dev/null 2>&1 && return
distro=$(grep ^ID= /usr/lib/os-release | cut -d= -f2)
pkgname="clang-tools-extra" # pkgname for fedora
case $distro in
fedora)
;;
raspbian)
pkgname=clangd-11
;;
ubuntu)
pkgname=clangd-11
;;
*)
echo >&2 "Error: could not install clangd for ${distro}"
exit 1;;
esac
__install_pkg ${pkgname}
unset pkgname
unset distro
}
function install_universal_ctags() {
# skip install if the right ctags is installed
command -v ctags > /dev/null 2>&1 && ctags --version | grep -qs '^Universal Ctags' && return
distro=$(grep ^ID= /usr/lib/os-release | cut -d= -f2)
case $distro in
fedora)
sudo -E dnf copr enable jgoguen/universal-ctags;;
raspbian)
;;
ubuntu)
;;
*)
echo >&2 "Error: could not install universal-ctags for ${distro}"
exit 1;;
esac
unset distro
__install_pkg universal-ctags
}
function install_nvim() {
# skip install if already installed
command -v nvim > /dev/null 2>&1 && return
distro=$(grep ^ID= /usr/lib/os-release | cut -d= -f2)
case $distro in
fedora)
sudo -E dnf copr enable agriffis/neovim-nightly
__install_pkg neovim;;
raspbian)
echo "Still Unsupported!";;
ubuntu)
pkgname=neovim
;;
*)
echo >&2 "Error: could not install neovim for ${distro}"
exit 1;;
esac
unset distro
}
function install_zsh() {
# skip install if already installed
command -v zsh > /dev/null 2>&1 && return
__install_pkg zsh
}
function install_tmux() {
# skip install if already installed
command -v tmux > /dev/null 2>&1 && return
__install_pkg tmux
}
function install_bat() {
# skip install if already installed
command -v bat > /dev/null 2>&1 && return
__install_cargo_pkg bat
}
function install_git_delta() {
# skip install if already installed
command -v delta > /dev/null 2>&1 && return
__install_cargo_pkg git-delta
}
function install_ohmyzsh() {
# skip clone if already exists
if [ -d $HOME/git/ohmyzsh ]; then
return
fi
command -v git >/dev/null 2>&1 || { echo >&2 "Install git to continue"; exit 1; }
mkdir -p $HOME/git &> /dev/null
git clone https://github.com/ohmyzsh/ohmyzsh.git $HOME/git/ohmyzsh
}
function install_rust() {
# skip install if already installed
command -v rustc > /dev/null 2>&1 && return
command -v curl >/dev/null 2>&1 || { echo >&2 "Install curl to continue"; exit 1; }
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
}