-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-devtools.sh
More file actions
executable file
·145 lines (129 loc) · 3.33 KB
/
setup-devtools.sh
File metadata and controls
executable file
·145 lines (129 loc) · 3.33 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
#!/usr/bin/env bash
set -euo pipefail
FORCE=0
for arg in "$@"; do
case "$arg" in
--force) FORCE=1 ;;
esac
done
log() { echo "[setup-devtools] $*"; }
die() { log "ERROR: $*"; exit 1; }
trap 'die "failed at line ${LINENO} (exit $?)"' ERR
if [[ "${EUID}" -eq 0 ]]; then
log "refusing to run as root/sudo. Run as a normal user; this step will use sudo internally as needed."
exit 1
fi
need_cmd() { command -v "$1" >/dev/null 2>&1; }
missing_core=0
for c in rg htop jq git; do
if ! need_cmd "$c"; then
missing_core=1
fi
done
if [[ "$FORCE" -ne 1 ]] && [[ "$missing_core" -eq 0 ]]; then
log "core dev tools already present (rg/htop/jq/git). Will still ensure optional tools and AI CLIs."
fi
log "installing common packages via apt"
sudo apt-get update -y
if [[ "$FORCE" -eq 1 ]]; then
sudo apt-get install -y --reinstall \
ripgrep \
htop \
git \
zip \
xz-utils \
build-essential \
pkg-config \
tree \
fzf \
tmux \
shellcheck \
openssh-client \
fd-find \
bat \
direnv
else
sudo apt-get install -y \
ripgrep \
htop \
git \
zip \
xz-utils \
build-essential \
pkg-config \
tree \
fzf \
tmux \
shellcheck \
openssh-client \
fd-find \
bat \
direnv
fi
# Ubuntu packages often ship as batcat/fdfind; provide convenience shims in ~/.local/bin.
mkdir -p "$HOME/.local/bin"
if command -v batcat >/dev/null 2>&1 && ! command -v bat >/dev/null 2>&1; then
ln -sf "$(command -v batcat)" "$HOME/.local/bin/bat"
fi
if command -v fdfind >/dev/null 2>&1 && ! command -v fd >/dev/null 2>&1; then
ln -sf "$(command -v fdfind)" "$HOME/.local/bin/fd"
fi
# Ensure ~/.local/bin is on PATH for bash shells.
if [[ -f "$HOME/.bashrc" ]]; then
start="# >>> setup-devtools >>>"
end="# <<< setup-devtools <<<"
if ! grep -Fq "$start" "$HOME/.bashrc" 2>/dev/null; then
{
echo
echo "$start"
echo 'export PATH="$HOME/.local/bin:$PATH"'
echo "$end"
} >>"$HOME/.bashrc"
fi
fi
export PATH="$HOME/.local/bin:$PATH"
log "installing AI CLIs (best-effort)"
if ! command -v curl >/dev/null 2>&1; then
die "missing 'curl'. Run ./setup.sh (or install curl) and try again."
fi
have_npm=0
if command -v npm >/dev/null 2>&1; then
have_npm=1
else
if command -v fnm >/dev/null 2>&1; then
# Try to make Node available in this non-interactive shell.
set +u
eval "$(fnm env --shell bash)"
set -u
if command -v npm >/dev/null 2>&1; then
have_npm=1
fi
fi
fi
if [[ "$have_npm" -eq 1 ]]; then
if [[ "$FORCE" -eq 1 ]] || ! command -v codex >/dev/null 2>&1; then
log "installing OpenAI Codex CLI (@openai/codex)"
npm i -g @openai/codex@latest
else
log "codex already present at: $(command -v codex)"
fi
else
log "npm not found; skipping Codex CLI install (run setup-fnm.sh first)."
fi
if [[ "$FORCE" -eq 1 ]] || ! command -v claude >/dev/null 2>&1; then
log "installing Claude Code (native installer)"
curl -fsSL "https://claude.ai/install.sh" | bash
else
log "claude already present at: $(command -v claude)"
fi
set +e
if command -v codex >/dev/null 2>&1; then
codex --version >/dev/null 2>&1
log "codex installed (version check exit $?)"
fi
if command -v claude >/dev/null 2>&1; then
claude --version >/dev/null 2>&1
log "claude installed (version check exit $?)"
fi
set -e
log "dev tools installed"