mirror of
https://github.com/LukeHagar/omarchy.git
synced 2025-12-06 04:20:23 +00:00
Theme support for Cursor (#2015)
* Imitating VSCode omarchy-theme-set * Changed VSCode theme setter take arguments to Cursor theme setter could call it. * All omarchy commands are in path --------- Co-authored-by: David Heinemeier Hansson <david@hey.com> Co-authored-by: @adelplace
This commit is contained in:
@@ -30,9 +30,10 @@ hyprctl reload
|
||||
pkill -SIGUSR2 btop
|
||||
makoctl reload
|
||||
|
||||
# Change gnome, browser, vscode themes
|
||||
# Change gnome, browser, vscode, cursor themes
|
||||
omarchy-theme-set-terminal
|
||||
omarchy-theme-set-gnome
|
||||
omarchy-theme-set-eza
|
||||
omarchy-theme-set-browser
|
||||
omarchy-theme-set-vscode
|
||||
omarchy-theme-set-cursor
|
||||
|
||||
4
bin/omarchy-theme-set-cursor
Executable file
4
bin/omarchy-theme-set-cursor
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Call the VSCode theme setter with Cursor-specific parameters
|
||||
omarchy-theme-set-vscode cursor "$HOME/.config/Cursor/User/settings.json" "$HOME/.local/state/omarchy/toggles/skip-cursor-theme-changes" Cursor
|
||||
@@ -3,43 +3,47 @@
|
||||
# Note: We cannot use `jq` to update settings.json because it’s JSONC (allows comments),
|
||||
# which jq doesn’t support.
|
||||
|
||||
VS_CODE_THEME="$HOME/.config/omarchy/current/theme/vscode.json"
|
||||
VS_CODE_SETTINGS="$HOME/.config/Code/User/settings.json"
|
||||
VS_CODE_SKIP_FLAG="$HOME/.local/state/omarchy/toggles/skip-vscode-theme-changes"
|
||||
# Parameters: EDITOR_CMD SETTINGS_PATH SKIP_FLAG EDITOR_NAME
|
||||
EDITOR_CMD="${1:-code}"
|
||||
SETTINGS_PATH="${2:-$HOME/.config/Code/User/settings.json}"
|
||||
SKIP_FLAG="${3:-$HOME/.local/state/omarchy/toggles/skip-vscode-theme-changes}"
|
||||
EDITOR_NAME="${4:-VS Code}"
|
||||
|
||||
if omarchy-cmd-present code && [[ ! -f "$VS_CODE_SKIP_FLAG" ]]; then
|
||||
VS_CODE_THEME="$HOME/.config/omarchy/current/theme/vscode.json"
|
||||
|
||||
if omarchy-cmd-present "$EDITOR_CMD" && [[ ! -f "$SKIP_FLAG" ]]; then
|
||||
if [[ -f "$VS_CODE_THEME" ]]; then
|
||||
theme_name=$(jq -r '.name' "$VS_CODE_THEME")
|
||||
extension=$(jq -r '.extension' "$VS_CODE_THEME")
|
||||
|
||||
# Install VS Code theme extension
|
||||
if [[ -n "$extension" ]] && ! code --list-extensions | grep -Fxq "$extension"; then
|
||||
notify-send " Installing VS Code theme for $theme_name"
|
||||
code --install-extension "$extension" >/dev/null
|
||||
# Install $EDITOR_NAME theme extension
|
||||
if [[ -n "$extension" ]] && ! "$EDITOR_CMD" --list-extensions | grep -Fxq "$extension"; then
|
||||
notify-send " Installing $EDITOR_NAME theme for $theme_name"
|
||||
"$EDITOR_CMD" --install-extension "$extension" >/dev/null
|
||||
fi
|
||||
|
||||
# Create config file if there isn't already one
|
||||
mkdir -p "$(dirname "$VS_CODE_SETTINGS")"
|
||||
if [[ ! -f "$VS_CODE_SETTINGS" ]]; then
|
||||
printf '{\n}\n' > "$VS_CODE_SETTINGS"
|
||||
mkdir -p "$(dirname "$SETTINGS_PATH")"
|
||||
if [[ ! -f "$SETTINGS_PATH" ]]; then
|
||||
printf '{\n}\n' > "$SETTINGS_PATH"
|
||||
fi
|
||||
|
||||
# Create a `workbench.colorTheme` entry in settings.
|
||||
if ! grep -q '"workbench.colorTheme"' "$VS_CODE_SETTINGS"; then
|
||||
# Create a `workbench.colorTheme` entry in settings.
|
||||
if ! grep -q '"workbench.colorTheme"' "$SETTINGS_PATH"; then
|
||||
# Insert `"workbench.colorTheme": "",` immediately after the first `{`
|
||||
# Use sed's first-match range (0,/{/) to only replace the first `{`
|
||||
sed -i --follow-symlinks -E '0,/\{/{s/\{/{\
|
||||
"workbench.colorTheme": "",/}' "$VS_CODE_SETTINGS"
|
||||
"workbench.colorTheme": "",/}' "$SETTINGS_PATH"
|
||||
fi
|
||||
|
||||
# Update theme
|
||||
sed -i --follow-symlinks -E \
|
||||
"s/(\"workbench.colorTheme\"[[:space:]]*:[[:space:]]*\")[^\"]*(\")/\1$theme_name\2/" \
|
||||
"$VS_CODE_SETTINGS"
|
||||
"$SETTINGS_PATH"
|
||||
else
|
||||
# Remove theme from settings.json when the theme doesn't have vscode support
|
||||
if [[ -f "$VS_CODE_SETTINGS" ]]; then
|
||||
sed -i --follow-symlinks -E '/"workbench\.colorTheme"[[:space:]]*:[^,}]*,?/d' "$VS_CODE_SETTINGS"
|
||||
# Remove theme from settings.json when the theme doesn't have $EDITOR_NAME support
|
||||
if [[ -f "$SETTINGS_PATH" ]]; then
|
||||
sed -i --follow-symlinks -E '/"workbench\.colorTheme"[[:space:]]*:[^,}]*,?/d' "$SETTINGS_PATH"
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user