-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·318 lines (283 loc) · 10.2 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·318 lines (283 loc) · 10.2 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#!/bin/bash
# trmnl installer — works on macOS, Linux, and WSL
# Usage: curl -fsSL https://raw.githubusercontent.com/useteploy/teploy-trmnl/main/install.sh | bash
set -e
TRMNL_REPO="useteploy/teploy-trmnl"
TRMNL_BRANCH="main"
INSTALL_DIR="$HOME/.local/share/trmnl"
BIN_DIR="$HOME/.local/bin"
# ── Colors ──────────────────────────────────────────
BLUE='\033[0;34m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
RED='\033[0;31m'
DIM='\033[2m'
BOLD='\033[1m'
NC='\033[0m'
info() { echo -e " ${GREEN}>${NC} $1"; }
warn() { echo -e " ${YELLOW}!${NC} $1"; }
error() { echo -e " ${RED}x${NC} $1"; exit 1; }
# ── Detect OS and package manager ───────────────────
detect_os() {
case "$(uname -s)" in
Darwin) OS="macos" ;;
Linux) OS="linux" ;;
*) error "Unsupported OS: $(uname -s)" ;;
esac
# Detect WSL
if [ "$OS" = "linux" ] && grep -qi microsoft /proc/version 2>/dev/null; then
OS="wsl"
fi
# Detect package manager
if command -v brew &>/dev/null; then
PKG="brew"
elif command -v apt-get &>/dev/null; then
PKG="apt"
elif command -v dnf &>/dev/null; then
PKG="dnf"
elif command -v pacman &>/dev/null; then
PKG="pacman"
elif command -v zypper &>/dev/null; then
PKG="zypper"
elif command -v apk &>/dev/null; then
PKG="apk"
else
PKG="none"
fi
}
# ── Install a package ───────────────────────────────
pkg_install() {
local pkg="$1"
local brew_name="${2:-$1}"
if command -v "$pkg" &>/dev/null; then
return 0
fi
case "$PKG" in
brew) brew install "$brew_name" ;;
apt) sudo apt-get install -y "$brew_name" ;;
dnf) sudo dnf install -y "$brew_name" ;;
pacman) sudo pacman -S --noconfirm "$brew_name" ;;
zypper) sudo zypper install -y "$brew_name" ;;
apk) sudo apk add "$brew_name" ;;
*) warn "Cannot install $pkg — no supported package manager found. Install it manually." ;;
esac
}
# ── Install core dependencies ───────────────────────
install_deps() {
echo ""
echo -e "${BOLD}Installing dependencies...${NC}"
echo ""
# These are available in most system package managers
local -A tools=(
[nvim]="neovim"
[fzf]="fzf"
[rg]="ripgrep"
[fd]="fd-find"
[bat]="bat"
[jq]="jq"
[git]="git"
[curl]="curl"
)
# Adjust package names per manager
if [ "$PKG" = "brew" ]; then
tools[fd]="fd"
tools[delta]="git-delta"
tools[eza]="eza"
tools[nvim]="neovim"
elif [ "$PKG" = "apt" ]; then
tools[fd]="fd-find"
tools[bat]="bat"
elif [ "$PKG" = "pacman" ]; then
tools[fd]="fd"
tools[bat]="bat"
tools[delta]="git-delta"
fi
for cmd in "${!tools[@]}"; do
if command -v "$cmd" &>/dev/null; then
info "$cmd already installed"
else
info "Installing ${tools[$cmd]}..."
pkg_install "$cmd" "${tools[$cmd]}" 2>/dev/null || warn "Failed to install ${tools[$cmd]} — install manually"
fi
done
# Tools that may need special install methods
echo ""
echo -e "${BOLD}Installing terminal tools...${NC}"
echo ""
# Zellij
if ! command -v zellij &>/dev/null; then
if [ "$PKG" = "brew" ]; then
brew install zellij
elif [ "$PKG" = "pacman" ]; then
sudo pacman -S --noconfirm zellij
else
info "Installing zellij via official installer..."
bash <(curl -fsSL https://zellij.dev/launch) 2>/dev/null || warn "Failed to install zellij — visit https://zellij.dev"
fi
else
info "zellij already installed"
fi
# Yazi
if ! command -v yazi &>/dev/null; then
if [ "$PKG" = "brew" ]; then
brew install yazi
elif [ "$PKG" = "pacman" ]; then
sudo pacman -S --noconfirm yazi
else
warn "Install yazi manually: https://yazi-rs.github.io/docs/installation"
fi
else
info "yazi already installed"
fi
# Lazygit
if ! command -v lazygit &>/dev/null; then
if [ "$PKG" = "brew" ]; then
brew install lazygit
elif [ "$PKG" = "pacman" ]; then
sudo pacman -S --noconfirm lazygit
elif [ "$PKG" = "dnf" ]; then
sudo dnf copr enable atim/lazygit -y && sudo dnf install -y lazygit
else
warn "Install lazygit manually: https://github.com/jesseduffield/lazygit#installation"
fi
else
info "lazygit already installed"
fi
# Starship
if ! command -v starship &>/dev/null; then
if [ "$PKG" = "brew" ]; then
brew install starship
else
info "Installing starship via official installer..."
curl -fsSL https://starship.rs/install.sh | sh -s -- -y 2>/dev/null || warn "Failed to install starship"
fi
else
info "starship already installed"
fi
# Zoxide
if ! command -v zoxide &>/dev/null; then
if [ "$PKG" = "brew" ]; then
brew install zoxide
else
info "Installing zoxide via official installer..."
curl -fsSL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh 2>/dev/null || warn "Failed to install zoxide"
fi
else
info "zoxide already installed"
fi
# Eza
if ! command -v eza &>/dev/null; then
if [ "$PKG" = "brew" ]; then
brew install eza
elif [ "$PKG" = "pacman" ]; then
sudo pacman -S --noconfirm eza
elif [ "$PKG" = "apt" ]; then
# eza needs the gierens PPA on Ubuntu
warn "Install eza manually: https://eza.rocks"
else
warn "Install eza manually: https://eza.rocks"
fi
else
info "eza already installed"
fi
# Delta
if ! command -v delta &>/dev/null; then
if [ "$PKG" = "brew" ]; then
brew install git-delta
elif [ "$PKG" = "pacman" ]; then
sudo pacman -S --noconfirm git-delta
else
warn "Install delta manually: https://github.com/dandavison/delta#installation"
fi
else
info "delta already installed"
fi
# Btop
if ! command -v btop &>/dev/null; then
pkg_install btop btop 2>/dev/null || warn "Install btop manually: https://github.com/aristocratos/btop"
else
info "btop already installed"
fi
# API + DB clients (atac = TUI API client, hurl = HTTP-as-code, lazysql = DB
# browser). Reliably packaged only via Homebrew; elsewhere point at upstream
# install docs. Graceful (warn, never fail) — consistent with the tools above.
for entry in "atac|https://github.com/Julien-cpsn/ATAC#installation" \
"hurl|https://hurl.dev/docs/installation.html" \
"lazysql|https://github.com/jorgerojas26/lazysql#installation"; do
cmd="${entry%%|*}"; link="${entry#*|}"
if ! command -v "$cmd" &>/dev/null; then
if [ "$PKG" = "brew" ]; then
brew install "$cmd" 2>/dev/null || warn "Failed to install $cmd — see $link"
else
warn "Install $cmd manually: $link"
fi
else
info "$cmd already installed"
fi
done
}
# ── Download and install trmnl configs ──────────────
install_configs() {
echo ""
echo -e "${BOLD}Installing trmnl configs...${NC}"
echo ""
# Clean previous install
if [ -d "$INSTALL_DIR" ]; then
info "Removing previous trmnl installation..."
rm -rf "$INSTALL_DIR"
fi
# Download repo
info "Downloading trmnl..."
mkdir -p "$INSTALL_DIR"
if command -v git &>/dev/null; then
git clone --depth 1 --branch "$TRMNL_BRANCH" "https://github.com/$TRMNL_REPO.git" "$INSTALL_DIR/repo" 2>/dev/null
cp -r "$INSTALL_DIR/repo/config/"* "$INSTALL_DIR/"
cp "$INSTALL_DIR/repo/bin/trmnl" "$INSTALL_DIR/trmnl-bin"
rm -rf "$INSTALL_DIR/repo"
else
error "git is required to install trmnl"
fi
# Install binary
mkdir -p "$BIN_DIR"
cat > "$BIN_DIR/trmnl" << 'WRAPPER'
#!/bin/bash
# trmnl wrapper — redirects TRMNL_DIR for non-Homebrew installs
export TRMNL_DIR="$HOME/.local/share/trmnl"
WRAPPER
# Append the actual script, replacing the brew --prefix line
sed 's|TRMNL_DIR="$(brew --prefix)/share/trmnl"|TRMNL_DIR="$HOME/.local/share/trmnl"|' \
"$INSTALL_DIR/trmnl-bin" | tail -n +2 >> "$BIN_DIR/trmnl"
chmod +x "$BIN_DIR/trmnl"
rm -f "$INSTALL_DIR/trmnl-bin"
info "Binary installed to $BIN_DIR/trmnl"
# Ensure ~/.local/bin is in PATH
if ! echo "$PATH" | grep -q "$BIN_DIR"; then
warn "$BIN_DIR is not in your PATH"
warn "Add this to your ~/.zshrc or ~/.bashrc:"
echo -e " ${BOLD}export PATH=\"\$HOME/.local/bin:\$PATH\"${NC}"
fi
}
# ── Main ────────────────────────────────────────────
main() {
echo ""
echo -e "${BLUE}${BOLD} ┌─────────────────────────────┐${NC}"
echo -e "${BLUE}${BOLD} │ trmnl installer │${NC}"
echo -e "${BLUE}${BOLD} │ Terminal IDE │${NC}"
echo -e "${BLUE}${BOLD} └─────────────────────────────┘${NC}"
echo ""
detect_os
info "Detected: $OS ($PKG)"
install_deps
install_configs
echo ""
echo -e "${GREEN}${BOLD} Installation complete!${NC}"
echo ""
echo -e " Run: ${BOLD}trmnl setup${NC} to link configs"
echo -e " Run: ${BOLD}trmnl doctor${NC} to verify installation"
echo -e " Run: ${BOLD}trmnl${NC} to launch"
echo ""
echo -e " ${DIM}For Nerd Font icons, install JetBrains Mono Nerd Font${NC}"
echo -e " ${DIM}Recommended terminal: Ghostty (https://ghostty.org)${NC}"
echo ""
}
main "$@"