Last active
October 22, 2025 17:20
-
-
Save essingen123/08948955ea95c2a0bba0b988be8a59d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #### `toggle-vscode-extensions-macos.sh` | |
| # (onliner at the bottom) | |
| > "AI kan ha fel, precis som människor. Låt inte AI ta bort fransk touch med `sudo rm -rf /` utan sandlåda. Samma sak med oförsiktig vinst-maximering." | |
| Ett interaktivt Zsh/Bash-script för macOS som säkert slår av eller på alla VS Code-plugins. | |
| Detta simulerar exakt samma process som att manuellt klicka "Disable" eller "Enable" i VS Code's UI genom att använda den officiella `extensions.json`-manifestfilen. | |
| **Användning:** Klistra in hela scriptet i din terminal och kör, eller spara som en fil (t.ex. `vsc-toggle.sh`) och kör den. | |
| --- | |
| ```bash | |
| #!/bin/zsh | |
| # --- Interaktivt script för att slå av/på alla VS Code-plugins --- | |
| echo "Vill du (d)isabla eller (e)nabla alla VS Code-plugins?" | |
| echo -n "Tryck [d] eller [e], sedan Enter: " | |
| read choice | |
| choice=$(echo "$choice" | tr '[:upper:]' '[:lower:]') | |
| DB_PATH="$HOME/Library/Application Support/Code/User/globalStorage/state.vscdb" | |
| MANIFEST_PATH="$HOME/.vscode/extensions/extensions.json" | |
| if [[ "$choice" == "d" ]]; then | |
| echo "Valde: Disable" | |
| echo " - Stänger VS Code..." | |
| osascript -e 'quit app "Visual Studio Code"' | |
| sleep 2 | |
| if [ ! -f "$MANIFEST_PATH" ]; then | |
| echo "Fel: Filen extensions.json hittades inte. Avbryter." | |
| exit 1 | |
| fi | |
| echo " - Bygger lista från manifest..." | |
| JSON_DATA=$(jq -c '[.[] | {id: .identifier.id, uuid: .identifier.uuid}]' "$MANIFEST_PATH") | |
| sleep 0.5 | |
| echo " - Uppdaterar databasen..." | |
| sqlite3 "$DB_PATH" "DELETE FROM ItemTable WHERE key='extensionsIdentifiers/disabled';" | |
| sqlite3 "$DB_PATH" "INSERT INTO ItemTable (key, value) VALUES ('extensionsIdentifiers/disabled', '$JSON_DATA');" | |
| sleep 1 | |
| echo "Klart! Alla plugins är nu disabled. Startar om VS Code." | |
| open -a "Visual Studio Code" | |
| elif [[ "$choice" == "e" ]]; then | |
| echo "Valde: Enable" | |
| echo " - Stänger VS Code..." | |
| osascript -e 'quit app "Visual Studio Code"' | |
| sleep 2 | |
| echo " - Återställer databasen..." | |
| sqlite3 "$DB_PATH" "DELETE FROM ItemTable WHERE key='extensionsIdentifiers/disabled';" | |
| sleep 1 | |
| echo "Klart! Alla plugins är nu enabled. Startar om VS Code." | |
| open -a "Visual Studio Code" | |
| else | |
| echo "Ogiltigt val. Avbryter." | |
| fi | |
| ``` | |
| # oneliner; triend and works perfectly. tweak as you wish.. know what you are doing before use.. so double check with a competent llm in case | |
| echo "Disable (d) eller Enable (e) alla extensions? [d/e]: "; read choice; choice=$(echo "$choice" | tr '[:upper:]' '[:lower:]'); if [[ "$choice" == "d" ]]; then osascript -e 'quit app "Visual Studio Code"' && echo "[1/3] VS Code stängt. Väntar 1 sekund..." && sleep 1 && db="$HOME/Library/Application Support/Code/User/globalStorage/state.vscdb" && manifest="$HOME/.vscode/extensions/extensions.json" && echo "[2/3] Bygger korrekt lista..." && json="$(cat "$manifest" | jq -c '[.[] | {id: .identifier.id, uuid: .identifier.uuid}]')" && sqlite3 "$db" "BEGIN; DELETE FROM ItemTable WHERE key='extensionsIdentifiers/disabled'; INSERT INTO ItemTable (key,value) VALUES ('extensionsIdentifiers/disabled', '$json'); COMMIT;" && echo "[3/3] DB uppdaterad. Disabled. Startar om." && open -a "Visual Studio Code"; elif [[ "$choice" == "e" ]]; then osascript -e 'quit app "Visual Studio Code"' && echo "[1/2] VS Code stängt. Väntar 1 sekund..." && sleep 1 && db="$HOME/Library/Application Support/Code/User/globalStorage/state.vscdb" && echo "[2/2] Återställer (Enable All)..." && sqlite3 "$db" "DELETE FROM ItemTable WHERE key='extensionsIdentifiers/disabled';" && echo "Klart. Startar om VS Code." && open -a "Visual Studio Code"; else echo "Ogiltigt val. Avbryter."; fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment