Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·234 lines (207 loc) · 5.57 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·234 lines (207 loc) · 5.57 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!/usr/bin/bash
usage() {
cat <<'EOF'
Usage: ./install.sh [COMPONENT]
./install.sh nvim --update
If no component is provided, all components are installed.
Components:
nvim
git-completion
lazygit
lazysql
lazydocker
lazy-docker Alias for lazydocker
Options:
--update Force update/reinstall Neovim
-h, --help Show this help message
EOF
}
normalize_component() {
case "$1" in
nvim | git-completion | lazygit | lazysql | lazydocker)
printf '%s\n' "$1"
return 0
;;
lazy-docker)
printf 'lazydocker\n'
return 0
;;
*)
return 1
;;
esac
}
TARGET=all
UPDATE_NVM=false
if [[ -n $CONFIG_DIR ]]; then
echo "Using CONFIG_DIR from environment: $CONFIG_DIR"
else
CONFIG_DIR=~/code/Th3Cod3/config
fi
while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
usage
exit 0
;;
--update)
UPDATE_NVM=true
shift
;;
*)
if normalized=$(normalize_component "$1"); then
if [[ "$TARGET" != "all" && "$TARGET" != "$normalized" ]]; then
echo "Only one component can be selected"
usage
exit 1
fi
TARGET="$normalized"
shift
else
echo "Unknown argument: $1"
usage
exit 1
fi
;;
esac
done
if [[ "$UPDATE_NVM" == "true" && "$TARGET" != "all" && "$TARGET" != "nvim" ]]; then
echo "--update can only be used with nvim"
usage
exit 1
fi
should_install() {
local component="$1"
[[ "$TARGET" == "all" || "$TARGET" == "$component" ]]
}
if should_install all; then
if [ -f /etc/arch-release ]; then
echo "Arch Linux detected"
sudo pacman -Sy && sudo pacman -S --needed base-devel ninja gettext cmake unzip curl \
php python go \
npm python-pip \
fzf tmux ripgrep git jq xclip
elif [ -f /etc/debian_version ]; then
echo "Debian based distro detected"
sudo apt update &&
sudo apt install build-essential ninja-build gettext cmake unzip curl \
php python3 golang \
npm python3-pip cargo \
fzf tmux ripgrep git jq xclip
elif [ -f /etc/fedora-release ]; then
echo "Fedora detected"
sudo dnf install -y \
@development-tools \
ninja-build gettext cmake unzip curl \
php python3 golang rust \
npm python3-pip cargo uv \
fzf tmux ripgrep git jq xclip gh pandoc-cli
else
echo "Unsupported distro"
exit 1
fi
fi
ARCH=$(uname -m)
if should_install all; then
sudo npm i -g n
sudo n 22
sudo npm i -g typescript @vue/typescript-plugin \
opencode-ai mcp-hub \
obsidian-headless
fi
if should_install all; then
mkdir -p ~/.tmux
git submodule init
git submodule update
fi
if should_install nvim; then
if [[ "$UPDATE_NVM" == "true" ]]; then
echo "Updating Neovim"
sudo rm -rf /usr/local/bin/nvim
fi
if command -v nvim || [[ -f /usr/local/bin/nvim ]]; then
echo "Neovim already installed"
else
# compile neovim
cd src/neovim
rm -rf build
make distclean
make deps CMAKE_BUILD_TYPE=RelWithDebInfo
git fetch --tags --force
git checkout stable --force
make CMAKE_BUILD_TYPE=RelWithDebInfo
sudo make install
cd ../..
fi
fi
if should_install git-completion; then
if [ -f ~/.git-completion.bash ]; then
echo "Git completion already installed"
else
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
fi
fi
if should_install lazygit; then
if [ -f /usr/local/bin/lazygit ]; then
echo "Lazygit already install"
else
mkdir -p bin
cd bin
if [ -f lazygit.tar.gz ]; then
rm lazygit.tar.gz
fi
# check if arm or x86 if arm set ARCH=armv6 otherwise ARCH=x86_64
LAZYGIT_ARCH="$ARCH"
if [[ $LAZYGIT_ARCH == "aarch64" ]]; then
LAZYGIT_ARCH=arm64
fi
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_${LAZYGIT_ARCH}.tar.gz"
tar xf lazygit.tar.gz lazygit
sudo install lazygit /usr/local/bin
rm lazygit.tar.gz lazygit
cd ..
fi
fi
if should_install lazysql; then
if [ -f /usr/local/bin/lazysql ]; then
echo "Lazysql already install"
else
mkdir -p bin
cd bin
if [ -f lazysql.tar.gz ]; then
rm lazysql.tar.gz
fi
# check if arm or x86 if arm set ARCH=armv6 otherwise ARCH=x86_64
LAZYSQL_ARCH="$ARCH"
if [[ $LAZYSQL_ARCH == "aarch64" ]]; then
LAZYSQL_ARCH=arm64
fi
curl -Lo lazysql.tar.gz "https://github.com/jorgerojas26/lazysql/releases/latest/download/lazysql_Linux_${LAZYSQL_ARCH}.tar.gz"
tar xf lazysql.tar.gz lazysql
sudo install lazysql /usr/local/bin
rm lazysql.tar.gz lazysql
cd ..
fi
fi
if should_install lazydocker; then
if [ -f /usr/local/bin/lazydocker ]; then
echo "Lazydocker already install"
else
curl https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | bash
sudo install ~/.local/bin/lazydocker /usr/local/bin
fi
fi
if [[ "$TARGET" == "all" ]]; then
ln -sf $CONFIG_DIR/tmux ~/.config/
ln -sf $CONFIG_DIR/alacritty ~/.config/
ln -sf $CONFIG_DIR/kitty ~/.config/
ln -sf $CONFIG_DIR/nvim ~/.config/
ln -sf $CONFIG_DIR/bash/.bash_aliases ~/.bash_aliases
ln -sf $CONFIG_DIR/bash/.bash_profile ~/.bash_profile
ln -sf $CONFIG_DIR/bash/.inputrc ~/.inputrc
ln -sf $CONFIG_DIR/git/.gitconfig ~/.gitconfig
mkdir -p ~/.config/lazygit
ln -sf $CONFIG_DIR/git/config.yml ~/.config/lazygit/config.yml
source ~/.bash_profile
fi