This commit is contained in:
David Heinemeier Hansson
2025-10-14 12:02:27 +03:00
parent 313dcd4468
commit 491e980dd9

View File

@@ -25,15 +25,14 @@ if omarchy-cmd-present "$EDITOR_CMD" && [[ ! -f "$SKIP_FLAG" ]]; then
# Create config file if there isn't already one # Create config file if there isn't already one
mkdir -p "$(dirname "$SETTINGS_PATH")" mkdir -p "$(dirname "$SETTINGS_PATH")"
if [[ ! -f "$SETTINGS_PATH" ]]; then if [[ ! -f "$SETTINGS_PATH" ]]; then
printf '{\n}\n' > "$SETTINGS_PATH" printf '{\n}\n' >"$SETTINGS_PATH"
fi fi
# Create a `workbench.colorTheme` entry in settings. # Create a `workbench.colorTheme` entry in settings.
if ! grep -q '"workbench.colorTheme"' "$SETTINGS_PATH"; then if ! grep -q '"workbench.colorTheme"' "$SETTINGS_PATH"; then
# Insert `"workbench.colorTheme": "",` immediately after the first `{` # Insert `"workbench.colorTheme": "",` immediately after the first `{`
# Use sed's first-match range (0,/{/) to only replace the first `{` # Use sed's first-match range (0,/{/) to only replace the first `{`
sed -i --follow-symlinks -E '0,/\{/{s/\{/{\ sed -i --follow-symlinks -E '0,/\{/{s/\{/{\ "workbench.colorTheme": "",/}' "$SETTINGS_PATH"
"workbench.colorTheme": "",/}' "$SETTINGS_PATH"
fi fi
# Update theme # Update theme
@@ -44,7 +43,6 @@ if omarchy-cmd-present "$EDITOR_CMD" && [[ ! -f "$SKIP_FLAG" ]]; then
# Remove theme from settings.json when the theme doesn't have $EDITOR_NAME support # Remove theme from settings.json when the theme doesn't have $EDITOR_NAME support
if [[ -f "$SETTINGS_PATH" ]]; then if [[ -f "$SETTINGS_PATH" ]]; then
sed -i --follow-symlinks -E '/"workbench\.colorTheme"[[:space:]]*:[^,}]*,?/d' "$SETTINGS_PATH" sed -i --follow-symlinks -E '/"workbench\.colorTheme"[[:space:]]*:[^,}]*,?/d' "$SETTINGS_PATH"
fi fi
fi fi
fi fi