Skip to content

Instantly share code, notes, and snippets.

@saamerm
Last active October 3, 2025 21:13
Show Gist options
  • Save saamerm/f83a6573776c696e6539ae4432542746 to your computer and use it in GitHub Desktop.
Save saamerm/f83a6573776c696e6539ae4432542746 to your computer and use it in GitHub Desktop.
Shell script to auto-restart your app on MacOs
#!/bin/bash
# To use this with any app, just change line 14 to your app's name.
# Works for if your app crashes or computer restarts
# Shell script to stop this functionality is here https://gist.github.com/saamerm/010215ab8c207cc4d7e96a7b09d9e130
PLIST=~/Library/LaunchAgents/com.confcap.autorestart.plist
cat > "$PLIST" <<EOL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.confcap.autorestart</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/ConfCap.app/Contents/MacOS/ConfCap</string>
</array>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOL
launchctl unload "$PLIST" 2>/dev/null
launchctl load "$PLIST"
echo "✅ Auto-restart enabled for ConfCap"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment