Files
jbrechtel 7f3769fcd8 feat: add SPINE_ORG env var to override org file path
Add SPINE_ORG environment variable support to scripts/run. When set,
the value is passed as spine-org-file via --eval before loading spine.el.

Usage:
  SPINE_ORG=~/my-books.org ./scripts/run
  SPINE_ORG=/work/personal-local/spine/sample-books.org ./scripts/run localhost:9090

When unset, defaults to ~/spine/books.org (existing behavior).
2026-06-23 22:19:51 -04:00

37 lines
844 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
HOST=""
PORT="8080"
if [ $# -ge 1 ] && [ -n "$1" ]; then
ARG="$1"
if [[ "$ARG" == *:* ]]; then
HOST="${ARG%:*}"
PORT="${ARG##*:}"
else
PORT="$ARG"
fi
EMACS_ARGS=(emacs --quick --daemon=spine)
# If SPINE_ORG env var is set, override the org file path
if [ -n "${SPINE_ORG:-}" ]; then
EMACS_ARGS+=(--eval "(setq spine-org-file \"$SPINE_ORG\")")
fi
if [ -n "$HOST" ]; then
EMACS_ARGS+=(--eval "(setq spine-host \"$HOST\")")
fi
EMACS_ARGS+=(--eval "(setq spine-port $PORT)")
EMACS_ARGS+=(--load "$ROOT_DIR/spine.el")
"${EMACS_ARGS[@]}"
DISPLAY_HOST="${HOST:-localhost}"
echo "Spine running at http://${DISPLAY_HOST}:${PORT}/hello"
echo "Stop: emacsclient --socket-name=spine --eval '(kill-emacs)'"