Created
February 21, 2026 16:01
-
-
Save tmort/2f12c9bef63310f49df6d1db1b03430b to your computer and use it in GitHub Desktop.
VSCode Custom Color
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
| #!/bin/bash | |
| # An array of deep, readable UI colors | |
| COLORS=( | |
| "#1E3A8A" # Deep Blue | |
| "#064E3B" # Dark Emerald | |
| "#7F1D1D" # Dark Red | |
| "#4C1D95" # Deep Purple | |
| "#78350F" # Amber/Brown | |
| "#0F766E" # Teal | |
| "#431407" # Rust | |
| "#312E81" # Indigo | |
| ) | |
| # Pick a random color from the list | |
| RANDOM_INDEX=$((RANDOM % ${#COLORS[@]})) | |
| BASE_COLOR=${COLORS[$RANDOM_INDEX]} | |
| echo "🎨 Setting workspace color to: $BASE_COLOR" | |
| # Ensure the .vscode directory exists | |
| mkdir -p .vscode | |
| FILE=".vscode/settings.json" | |
| # Create the file with an empty JSON object if it doesn't exist | |
| if [ ! -f "$FILE" ]; then | |
| echo "{}" > "$FILE" | |
| fi | |
| # Use Python to safely update the JSON without breaking existing settings | |
| python3 -c " | |
| import json | |
| file_path = '$FILE' | |
| color = '$BASE_COLOR' | |
| try: | |
| with open(file_path, 'r') as f: | |
| data = json.load(f) | |
| except (json.JSONDecodeError, FileNotFoundError): | |
| data = {} | |
| if 'workbench.colorCustomizations' not in data: | |
| data['workbench.colorCustomizations'] = {} | |
| data['workbench.colorCustomizations'].update({ | |
| 'activityBar.background': color, | |
| 'titleBar.activeBackground': color, | |
| 'titleBar.activeForeground': '#FFFFFF' | |
| }) | |
| with open(file_path, 'w') as f: | |
| json.dump(data, f, indent=4) | |
| " | |
| echo "✅ Bam, it's there! Reload your editor to see the changes." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment