How to launch TiddlyWiki at startup on Mac

30th December 2020 at 1:08am

http://undefinedvalue.com/setting-personal-tiddlywiki-server-os-x.html

Create the file com.tiddlywiki.plist in the directory ~/Library/LaunchAgents:

<?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.tiddlywiki</string>
  <key>ProgramArguments</key>
  <array>
    <string>/opt/homebrew/bin/node</string>
    <string>/opt/homebrew/bin/tiddlywiki</string>
    <string>/Users/arnaud/Projects/wiki</string>
    <string>--server</string>
    <string>8000</string>
  </array>
  <key>EnvironmentVariables</key>
  <dict>
    <key>PATH</key>
    <string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
  </dict>
  <key>RunAtLoad</key>
  <true/>
  <key>WorkingDirectory</key>
  <string>/Users/arnaud/Projects/wiki</string>
  <key>StandardErrorPath</key>
  <string>error.log</string>
  <key>StandardOutputPath</key>
  <string>output.log</string>
</dict>
</plist>

I also added some aliases to restart TiddlyWiki:

export TWPLIST=~/Library/LaunchAgents/com.tiddlywiki.plist
alias twstart="launchctl load $TWPLIST"
alias twstop="launchctl unload $TWPLIST"
alias twrestart="twstop && sleep 1 && twstart && echo 'TiddlyWiki restarted'"