Last active
May 28, 2025 08:21
-
-
Save nuc/11512c94b6f301774c6393e8de57bed1 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
#!/bin/bash | |
# Path definitions | |
CURSOR_USER_DIR="$HOME/Library/Application Support/Cursor/User" | |
ICLOUD_DIR="$HOME/Library/Mobile Documents/com~apple~CloudDocs/cursor-sync" | |
SETTINGS="settings.json" | |
VSCDB="globalStorage/state.vscdb" | |
# Ensure iCloud dir exists | |
mkdir -p "$ICLOUD_DIR/globalStorage" | |
export_settings() { | |
echo "Exporting local Cursor settings to iCloud..." | |
# Quit Cursor | |
osascript -e 'quit app "Cursor"' | |
# Copy settings.json | |
cp "$CURSOR_USER_DIR/$SETTINGS" "$ICLOUD_DIR/$SETTINGS" | |
mv "$CURSOR_USER_DIR/$SETTINGS" "$CURSOR_USER_DIR/$SETTINGS.bak" | |
ln -sf "$ICLOUD_DIR/$SETTINGS" "$CURSOR_USER_DIR/$SETTINGS" | |
# Copy state.vscdb | |
cp "$CURSOR_USER_DIR/$VSCDB" "$ICLOUD_DIR/$VSCDB" | |
mv "$CURSOR_USER_DIR/$VSCDB" "$CURSOR_USER_DIR/$VSCDB.bak" | |
ln -sf "$ICLOUD_DIR/$VSCDB" "$CURSOR_USER_DIR/$VSCDB" | |
echo "Done! Settings exported and symlinked from iCloud." | |
open -a "Cursor" | |
} | |
import_settings() { | |
echo "Importing Cursor settings from iCloud..." | |
# Quit Cursor | |
osascript -e 'quit app "Cursor"' | |
# Backup and remove current settings.json | |
if [ -f "$CURSOR_USER_DIR/$SETTINGS" ]; then | |
mv "$CURSOR_USER_DIR/$SETTINGS" "$CURSOR_USER_DIR/$SETTINGS.bak" | |
fi | |
ln -sf "$ICLOUD_DIR/$SETTINGS" "$CURSOR_USER_DIR/$SETTINGS" | |
# Backup and remove current state.vscdb | |
if [ -f "$CURSOR_USER_DIR/$VSCDB" ]; then | |
mv "$CURSOR_USER_DIR/$VSCDB" "$CURSOR_USER_DIR/$VSCDB.bak" | |
fi | |
ln -sf "$ICLOUD_DIR/$VSCDB" "$CURSOR_USER_DIR/$VSCDB" | |
echo "Done! Settings are now symlinked from iCloud." | |
open -a "Cursor" | |
} | |
usage() { | |
echo "Usage: $0 [--export | --import]" | |
echo " --export Export local Cursor settings to iCloud" | |
echo " --import Import and symlink settings from iCloud" | |
} | |
case "$1" in | |
--export) export_settings ;; | |
--import) import_settings ;; | |
*) usage ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment