Skip to content

Instantly share code, notes, and snippets.

@osteele
Created January 22, 2016 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osteele/564d5374dc8657170a8b to your computer and use it in GitHub Desktop.
Save osteele/564d5374dc8657170a8b to your computer and use it in GitHub Desktop.
install-jupyter-launchagent.sh
#!/bin/bash -eu
die() { echo "$@" 1>&2 ; exit 1; }
LAUNCH_AGENTS_DIR=~/Library/LaunchAgents
[[ -d $LAUNCH_AGENTS_DIR ]] || die "Missing directory: $LAUNCH_AGENTS_DIR. Are you sure you're on a Mac?"
NOTEBOOK_DIR=~/code/notebooks
[[ -d $NOTEBOOK_DIR ]] || die "Missing directory: $NOTEBOOK_DIR"
cat > $LAUNCH_AGENTS_DIR/org.jupyter.notebook.plist <<EOT
<?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>KeepAlive</key>
<true/>
<key>Label</key>
<string>org.jupyter.notebook</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/jupyter-notebook</string>
<string>--no-browser</string>
<string>--port</string>
<string>8888</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>$NOTEBOOK_DIR</string>
<key>StandardErrorPath</key>
<string>/usr/local/var/log/jupyter-errors.log</string>
<key>StandardOutPath</key>
<string>/usr/local/var/log/jupyter.log</string>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment