-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvscode-tools-install.sh
More file actions
executable file
·185 lines (163 loc) · 4.98 KB
/
vscode-tools-install.sh
File metadata and controls
executable file
·185 lines (163 loc) · 4.98 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
#!/bin/bash
# =============================================
# 🛠️ VS Code + Extensions Installer
# =============================================
# --- Status tracking ---
declare -A STATUS
mark_status() {
local name="$1"
local status="$2"
STATUS["$name"]="$status"
}
# --- Determine if sudo is needed ---
if [ "$(id -u)" -eq 0 ]; then
SUDO=""
else
if command -v sudo &>/dev/null; then
SUDO="sudo"
else
echo "⚠️ No sudo and not root. Package installation may fail."
SUDO=""
fi
fi
# =============================================
# 1. Install VS Code
# =============================================
echo "🚀 VS Code Setup..."
echo ""
if command -v code &>/dev/null; then
echo "✅ VS Code is already installed."
mark_status "vscode" "already installed"
else
read -rp "📦 VS Code not found. Install? [Y/n]: " answer
answer="${answer:-Y}"
if [[ "$answer" =~ ^[Yy]$ ]]; then
echo "⬇️ Installing VS Code..."
# Install dependencies
$SUDO apt update -qq
$SUDO apt install -y -qq wget gpg apt-transport-https
# Add Microsoft GPG key
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/packages.microsoft.gpg
$SUDO install -D -o root -g root -m 644 /tmp/packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
rm -f /tmp/packages.microsoft.gpg
# Add VS Code repository
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" \
| $SUDO tee /etc/apt/sources.list.d/vscode.list > /dev/null
# Install
$SUDO apt update -qq
if $SUDO apt install -y -qq code; then
mark_status "vscode" "installed"
else
mark_status "vscode" "failed"
echo "🔴 VS Code installation failed. Skipping extensions."
exit 1
fi
else
echo "⏭️ Skipping VS Code."
mark_status "vscode" "skipped"
exit 0
fi
fi
# =============================================
# 2. Install Extensions
# =============================================
echo ""
echo "🧩 Installing extensions..."
echo ""
EXTENSIONS=(
aaron-bond.better-comments
almenon.arepl
ash-blade.postgresql-hacker-helper
eamodio.gitlens
esbenp.prettier-vscode
github.copilot-chat
johnpapa.vscode-peacock
kevinrose.vsc-python-indent
ms-azuretools.vscode-containers
ms-azuretools.vscode-docker
ms-python.debugpy
ms-python.python
ms-python.vscode-pylance
ms-python.vscode-python-envs
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode.cmake-tools
ms-vscode.cpp-devtools
ms-vscode.cpptools
ms-vscode.cpptools-extension-pack
ms-vscode.cpptools-themes
ms-vscode.makefile-tools
ms-vscode.remote-explorer
mumarshahbaz.als
nstechbytes.html-view
oderwat.indent-rainbow
pkief.material-icon-theme
quicktype.quicktype
tonybaloney.vscode-pets
wolfieshorizon.python-auto-venv
)
# Get already installed extensions once
INSTALLED=$(code --list-extensions 2>/dev/null)
for ext in "${EXTENSIONS[@]}"; do
ext_lower=$(echo "$ext" | tr '[:upper:]' '[:lower:]')
if echo "$INSTALLED" | tr '[:upper:]' '[:lower:]' | grep -qx "$ext_lower"; then
echo " ✅ $ext — already installed"
mark_status "$ext" "already installed"
else
if code --install-extension "$ext" --force 2>/dev/null; then
echo " 🟢 $ext — installed"
mark_status "$ext" "installed"
else
echo " 🔴 $ext — failed"
mark_status "$ext" "failed"
fi
fi
done
# =============================================
# Summary
# =============================================
echo ""
echo "==========================================="
echo " 📋 Installation Summary"
echo "==========================================="
# VS Code status
st="${STATUS[vscode]:-unknown}"
case "$st" in
"installed") icon="🟢 Installed" ;;
"already installed") icon="🔵 Already existed" ;;
"skipped") icon="🟡 Skipped" ;;
"failed") icon="🔴 Failed" ;;
*) icon="⚪ Unknown" ;;
esac
printf "\n %-40s %s\n" "VS Code" "$icon"
# Extensions summary
ext_installed=0
ext_existed=0
ext_failed=0
failed_list=()
for ext in "${EXTENSIONS[@]}"; do
st="${STATUS[$ext]:-unknown}"
case "$st" in
"installed") ((ext_installed++)) ;;
"already installed") ((ext_existed++)) ;;
"failed") ((ext_failed++)); failed_list+=("$ext") ;;
esac
done
echo ""
echo " Extensions:"
echo " ────────────────────────────────────────"
printf " 🟢 Installed: %d\n" "$ext_installed"
printf " 🔵 Already existed: %d\n" "$ext_existed"
printf " 🔴 Failed: %d\n" "$ext_failed"
if [ ${#failed_list[@]} -gt 0 ]; then
echo ""
echo " Failed extensions:"
for f in "${failed_list[@]}"; do
echo " ❌ $f"
done
fi
echo ""
echo "==========================================="
echo ""
echo "✅ Done! 🎉"