Skip to content

Commit f05ab67

Browse files
authored
Merge pull request #299 from abdibaker/fix-sudo-home-path
fix: correctly identify storage file path when run with sudo
2 parents d7044b6 + 92d88d2 commit f05ab67

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/run/cursor_linux_id_modifier.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ if [ -z "$CURRENT_USER" ]; then
4343
fi
4444

4545
# 定义配置文件路径
46-
STORAGE_FILE="$HOME/.config/Cursor/User/globalStorage/storage.json"
47-
BACKUP_DIR="$HOME/.config/Cursor/User/globalStorage/backups"
46+
if [ "$EUID" -eq 0 ] && [ -n "$SUDO_USER" ]; then
47+
USER_HOME=$(eval echo ~$SUDO_USER)
48+
else
49+
USER_HOME="$HOME"
50+
fi
51+
STORAGE_FILE="$USER_HOME/.config/Cursor/User/globalStorage/storage.json"
52+
BACKUP_DIR="$USER_HOME/.config/Cursor/User/globalStorage/backups"
4853

4954
# 检查权限
5055
check_permissions() {

0 commit comments

Comments
 (0)