#!/bin/zsh # Start bellows on 127.0.0.1 and open it in a Chrome incognito window. # Nothing is reachable from outside this machine. # Incognito keeps extensions out and leaves nothing of the input box on disk after you close it. # To stop the server, double-click stop.command. DIR="$(cd "$(dirname "$0")" && pwd)" PORT=8782 URL="http://127.0.0.1:${PORT}/" LOG="${TMPDIR:-/tmp}/bellows-server.log" if ! curl -s -o /dev/null --max-time 1 "$URL"; then nohup python3 "$DIR/app/server.py" "$PORT" "$LOG" 2>&1 &! for i in {1..30}; do curl -s -o /dev/null --max-time 1 "$URL" && break sleep 0.2 done fi if [ -d "/Applications/Google Chrome.app" ]; then open -na "Google Chrome" --args --incognito --new-window "$URL" else open "$URL" fi # Close the Terminal window this script opened WID=$(osascript -e "tell application \"Terminal\" to get id of (first window whose tty of selected tab is \"$(tty)\")" 2>/dev/null) [ -n "$WID" ] && ( sleep 0.5; osascript -e "tell application \"Terminal\" to close window id $WID" ) /dev/null 2>&1 &! exit 0