-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_dev_tools.sh
More file actions
executable file
·244 lines (198 loc) · 6.19 KB
/
install_dev_tools.sh
File metadata and controls
executable file
·244 lines (198 loc) · 6.19 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
235
236
237
238
239
240
241
242
243
244
#!/usr/bin/env zsh
set -x
set -e
OLD_DOTFILES="dotfile_bk_shell_setup_$(date -u +"%Y%m%d%H%M%S")"
mkdir $OLD_DOTFILES
function backup_if_exists() {
if [ -f $1 ];
then
cp -rp $1 $OLD_DOTFILES
fi
}
# Clean common conflicts
backup_if_exists ~/.bash_profile
backup_if_exists ~/.bashrc
backup_if_exists ~/.zshrc
backup_if_exists ~/.gitconfig
backup_if_exists ~/.tmux.conf
backup_if_exists ~/.profile
#######################
# BIN
#######################
function pull_repo() {
cd $1
git pull
cd -
}
mkdir -p $HOME/bin
# FASD
if [[ ! -f $HOME/bin/fasd ]]; then
git clone https://github.com/clvv/fasd.git /tmp/fasd
cd /tmp/fasd
PREFIX=$HOME make install
cd -
fi
# FZF
if [[ ! -f $HOME/.fzf/bin/fzf ]]; then
git clone https://github.com/junegunn/fzf.git $HOME/.fzf
yes | $HOME/.fzf/install
fi
#######################
# TMUX
#######################
if [[ ! -d $HOME/.tmux/plugins/tpm ]]; then
mkdir -p $HOME/.tmux/plugins
git clone https://github.com/tmux-plugins/tpm $HOME/.tmux/plugins/tpm
fi
pull_repo $HOME/.tmux/plugins/tpm
#######################
# ZSH
#######################
if [[ ! -d $HOME/.zprezto ]]; then
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/'^README.md(.N)'; do
# -L returns true if the "file" exists and is a symbolic link (the linked file may or may not exist).
if [ -L "${ZDOTDIR:-$HOME}/.${rcfile:t}" ]; then
echo "remove softlink ${ZDOTDIR:-$HOME}/.${rcfile:t}"
rm -f "${ZDOTDIR:-$HOME}/.${rcfile:t}"
else
echo "backup file: ${ZDOTDIR:-$HOME}/.${rcfile:t}"
backup_if_exists "${ZDOTDIR:-$HOME}/.${rcfile:t}"
fi
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
fi
cd $HOME/.zprezto
git pull
git submodule update --init --recursive
cd -
mkdir -p $HOME/.zsh
# Fast syntax highlighting
if [[ ! -d $HOME/.zsh/fast-syntax-highlighting ]]; then
# git clone https://github.com/zdharma/fast-syntax-highlighting.git $HOME/.zsh/fast-syntax-highlighting
git clone git@github.com:purelind/fast-syntax-highlighting.git $HOME/.zsh/fast-syntax-highlighting
fi
pull_repo $HOME/.zsh/fast-syntax-highlighting
#######################
# NEOVIM
#######################
NVIM=$HOME/.neovim
mkdir -p $NVIM
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
echo ${machine}
# AppImage in case the computer does not have a fallback nvim (appimage does not self update)
if command -v nvim > /dev/null; then
echo "NVIM appears to be installed"
else
mkdir -p $NVIM/bin
cd $NVIM/bin
if [[ $machine == "Mac" ]]; then
brew install nvim
else
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod u+x nvim.appimage
mv nvim.appimage nvim
fi
cd -
fi
# Create Python3 environment (requires pyenv or system python3)
if ! command -v python3 > /dev/null; then
echo "WARNING: python3 not found. Install via pyenv: brew install pyenv && pyenv install 3.12"
fi
if [[ ! -d $NVIM/py3 ]]; then
python3 -m venv $NVIM/py3
PIP=$NVIM/py3/bin/pip
$PIP install --upgrade pip
$PIP install neovim
$PIP install 'python-language-server[all]'
$PIP install pylint isort jedi flake8
$PIP install black yapf
fi
# Create node env
NODE_VERSION="v24.13.0"
CURRENT_NODE=$($NVIM/node/bin/node --version 2>/dev/null || echo "none")
if [[ "$CURRENT_NODE" != "$NODE_VERSION" ]]; then
# Backup global packages before upgrade
if [[ -d $NVIM/node ]]; then
echo "Upgrading Node from $CURRENT_NODE to $NODE_VERSION"
GLOBAL_PKGS=$($NVIM/node/bin/npm list -g --depth=0 --parseable 2>/dev/null | tail -n +2 | sed 's|.*/||' | grep -v "^npm$" || true)
rm -rf $NVIM/node
fi
# Install node
mkdir -p $NVIM/node
curl -sL install-node.now.sh/$NODE_VERSION -o /tmp/install-node.sh
chmod +x /tmp/install-node.sh
PREFIX=$NVIM/node /tmp/install-node.sh -y
PATH="$NVIM/node/bin:$PATH"
npm install -g neovim
# Restore global packages
[[ -n "${GLOBAL_PKGS:-}" ]] && echo "$GLOBAL_PKGS" | xargs npm install -g
fi
# DIFF-SO-FANCY
if [[ ! -f $NVIM/node/bin/diff-so-fancy ]]; then
npm install -g diff-so-fancy
fi
#######################
# RUST
#######################
if [[ ! -d $HOME/.rustup ]]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
fi
for crate in bat fd-find ripgrep tealdeer procs ytop hyperfine bandwhich jnv
do
$HOME/.cargo/bin/cargo install $crate
done
# workaroud for exa
# cargo install exa failed in debian-11 (20220522)
# issue : https://github.com/ogham/exa/issues/1068
for crate in exa
do
$HOME/.cargo/bin/rustup override set 1.66.1
$HOME/.cargo/bin/cargo install $crate
$HOME/.cargo/bin/rustup override unset
done
#######################
# GO
#######################
GO_VERSION="1.25.6"
GO_INSTALL_DIR="$HOME/.go"
# Detect OS and architecture
case "$(uname -s)" in
Linux*) GO_OS="linux" ;;
Darwin*) GO_OS="darwin" ;;
*) echo "Unsupported OS"; exit 1 ;;
esac
case "$(uname -m)" in
x86_64) GO_ARCH="amd64" ;;
arm64|aarch64) GO_ARCH="arm64" ;;
*) echo "Unsupported architecture"; exit 1 ;;
esac
CURRENT_GO=$($GO_INSTALL_DIR/bin/go version 2>/dev/null | grep -oE 'go[0-9]+\.[0-9]+\.[0-9]+' | sed 's/go//' || echo "none")
if [[ "$CURRENT_GO" != "$GO_VERSION" ]]; then
echo "Installing Go $GO_VERSION (current: $CURRENT_GO)"
rm -rf "$GO_INSTALL_DIR"
mkdir -p "$GO_INSTALL_DIR"
GO_TARBALL="go${GO_VERSION}.${GO_OS}-${GO_ARCH}.tar.gz"
curl -LO "https://go.dev/dl/${GO_TARBALL}"
tar -C "$GO_INSTALL_DIR" -xzf "$GO_TARBALL" --strip-components=1
rm -f "$GO_TARBALL"
echo "Go $GO_VERSION installed to $GO_INSTALL_DIR"
else
echo "Go $GO_VERSION already installed"
fi
#######################
# PNPM
#######################
if ! command -v pnpm > /dev/null; then
curl -fsSL https://get.pnpm.io/install.sh | sh -
else
echo "pnpm already installed: $(pnpm --version)"
fi