Skip to content

Instantly share code, notes, and snippets.

@jniltinho
Last active March 9, 2025 22:14
Show Gist options
  • Save jniltinho/25b21daef6c17907064959f6008d9196 to your computer and use it in GitHub Desktop.
Save jniltinho/25b21daef6c17907064959f6008d9196 to your computer and use it in GitHub Desktop.
Cursor IDE AppImage Launcher (Linux)
#!/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