Last active
March 9, 2025 22:14
-
-
Save jniltinho/25b21daef6c17907064959f6008d9196 to your computer and use it in GitHub Desktop.
Cursor IDE AppImage Launcher (Linux)
This file contains 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
#!/usr/bin/env bash | |
# | |
# Cursor IDE AppImage Launcher v0.3.0 | |
# | |
# Launches Cursor IDE with proper path handling and logging. | |
# | |
# 2025-03-01: Support for wait flag added. | |
# 2025-02-21: Created by monnef and Claude 3.6 Sonnet via Perplexity + AIlin and Cursor | |
# | |
# License: GPLv3 | |
# AIlin: cursor | |
APPIMAGE_DIR="$HOME/Applications" | |
# Enable error handling | |
set -e | |
trap 'echo "Error occurred at line $LINENO" >&2' ERR | |
# Setup logging | |
LOGFILE="/tmp/cursor.log" | |
exec 1> >(tee -a "$LOGFILE") 2>&1 | |
log() { | |
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | |
} | |
CURSOR_APPIMAGE=$(ls -t "$APPIMAGE_DIR"/cursor-*.AppImage | head -n 1) | |
if [ -z "$CURSOR_APPIMAGE" ]; then | |
log "β Error: Cursor AppImage not found in $APPIMAGE_DIR" | |
exit 1 | |
fi | |
log "π Found Cursor AppImage: $CURSOR_APPIMAGE" | |
# Convert all file arguments to absolute paths | |
args=() | |
for arg in "$@"; do | |
if [ -e "$arg" ]; then | |
args+=("$(realpath "$arg")") | |
log "π Converting path: $arg -> $(realpath "$arg")" | |
else | |
args+=("$arg") | |
log "π Keeping argument as-is: $arg" | |
fi | |
done | |
# Check if --wait is in the arguments | |
if [[ " ${args[*]} " == *" --wait "* ]]; then | |
log "π Running in foreground due to --wait flag" | |
"$CURSOR_APPIMAGE" --no-sandbox "${args[@]}" >> "$LOGFILE" 2>&1 | |
exit $? | |
else | |
log "π Launching in background" | |
"$CURSOR_APPIMAGE" --no-sandbox "${args[@]}" >> "$LOGFILE" 2>&1 & | |
CURSOR_PID=$! | |
# Verify process started successfully | |
sleep 1 | |
if ! kill -0 "$CURSOR_PID" 2>/dev/null; then | |
log "β Error: Cursor failed to start" | |
exit 1 | |
fi | |
log "β¨ Cursor launched successfully (PID: $CURSOR_PID)" | |
disown "$CURSOR_PID" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment