Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is this script so freaking complicated for no reason? #57

Open
avarayr opened this issue Dec 18, 2024 · 4 comments
Open

Why is this script so freaking complicated for no reason? #57

avarayr opened this issue Dec 18, 2024 · 4 comments

Comments

@avarayr
Copy link

avarayr commented Dec 18, 2024

I truly don't understand. Thousands upon thousands of lines of code just to do a simple text substitution in a file.

multilingual support. Progress tracking. Multi-arch binary compilation. GitHub release automation. Wtf? Is this project your PhD thesis?

This can be a 5 line bash script.

  1. Generate random uuid
  2. Replace inside the config file.

Hell you can probably do this in one single line....

@NicoleGoldMan
Copy link

Do not BB, show your code.

@avarayr
Copy link
Author

avarayr commented Dec 19, 2024

@NicoleGoldMan what does BB mean?

MacOS below, can be adapted to any OS with help of chatgpt.

#!/bin/bash

# Set config file path
c="$HOME/library/application support/cursor/user/globalstorage/storage.json"

# Kill existing Cursor processes (case-insensitive)
pkill -f "Cursor"; pkill -f "cursor"

# Generate new machine and device IDs: 
# m: random hex string -> sha256 hash -> first word
# d: unique UUID
m=$(openssl rand -hex 32|sha256sum|cut -d' ' -f1); d=$(uuidgen)

# check if file exists
if [ ! -f "$c" ]; then
   echo "Couldn't find the config file, are you on Mac?"
else
    # modify the json values
    sudo jq --arg m "$m" --arg d "$d" '.["telemetry.macMachineId"] = $m | .["telemetry.machineId"] = $m | .["telemetry.devDeviceId"] = $d' "$c" > "$c".tmp && mv "$c".tmp "$c"
fi


# Set config file permissions to read-only (444) for all users
sudo chmod 444 "$c"

# Inform the user that the operation was successful and requires a restart
echo "Cursor IDs reset. Restart Cursor."

@avarayr
Copy link
Author

avarayr commented Dec 19, 2024

Just to prove a point.

c="$HOME/Library/Application Support/Cursor/user/globalstorage/storage.json"
m=$(openssl rand -hex 32|sha256sum|cut -d' ' -f1)
d=$(uuidgen)
[[ ! -f "$c" ]] && echo "config not found" || sudo jq --arg m "$m" --arg d "$d" '."telemetry.macMachineId"=$m|."telemetry.machineId"=$m|."telemetry.devDeviceId"=$d' "$c">"$c".tmp&&mv "$c".tmp "$c"
sudo chmod 444 "$c"

@yuaotian
Copy link
Owner

Haha yeah, you're absolutely right - if it's just about modifying a config file, a few lines of bash script would do the job.
The code grew this large mainly because:
. Many users are beginners who don't even know how to use command line
. We kept running into various weird system environments and config issues
. To handle these problems, we gradually added more features
If you're familiar with development, you can totally:
Write your own script
Follow the manual config guide
Compile it yourself
These would be much more straightforward. Thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants