-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.code.sh
More file actions
executable file
·36 lines (30 loc) · 976 Bytes
/
.code.sh
File metadata and controls
executable file
·36 lines (30 loc) · 976 Bytes
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
#!/usr/bin/env bash
# Launch VS Code with only the extensions recommended for this project.
# Reads .vscode/extensions.json and disables everything else.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
EXTENSIONS_JSON="$SCRIPT_DIR/.vscode/extensions.json"
if [[ ! -f "$EXTENSIONS_JSON" ]]; then
echo "No .vscode/extensions.json found — launching VS Code normally." >&2
code "$SCRIPT_DIR"
exit 0
fi
# Wanted extensions (lowercased for case-insensitive comparison)
mapfile -t WANTED < <(
jq -r '.recommendations[]' "$EXTENSIONS_JSON" | tr '[:upper:]' '[:lower:]'
)
DISABLE_FLAGS=()
while IFS= read -r ext; do
ext_lower="${ext,,}"
match=false
for wanted in "${WANTED[@]}"; do
if [[ "$ext_lower" == "$wanted" ]]; then
match=true
break
fi
done
if [[ "$match" == false ]]; then
DISABLE_FLAGS+=("--disable-extension" "$ext")
fi
done < <(code --list-extensions)
code "${DISABLE_FLAGS[@]}" "$SCRIPT_DIR"