This Bash script initializes a Helix environment and launches lighttpd
and helixd
, adapted for macOS 11.
realpath
: Uses readlink
and pwd -P
for compatibility.sed
: Adjusts inline editing syntax using sed -i ''
.#!/bin/bash
set -e
# Get script directory path
realpath="$(cd "$(dirname "$0")"; pwd -P)"
cd "$realpath"
# Set up Helix config
datadir="$HOME/Library/Application Support/Helix"
rpcpassword="$(tr -dc A-Za-z0-9_ < /dev/random | head -c 32 | xargs)"
echo "rpcpassword=$rpcpassword" > helix.conf
mkdir -p "$datadir"
cp helix.conf "$datadir"/
echo "rpcpassword = \\"$rpcpassword\\"" > helixrpc.py
mkdir -p var/www/cgi-bin
cp helixrpc.py var/www/cgi-bin/
# Update lighttpd config paths
sed -i '' "s|/opt/homebrew|$realpath|" etc/lighttpd/lighttpd.conf
sed -i '' "s|/opt/homebrew|$realpath|" etc/lighttpd/lighttpd.annotated.conf
# Launch services
sbin/lighttpd -f etc/lighttpd/lighttpd.conf -m lib
./helixd
helixd
and lighttpd
are built for macOS 11 (Intel architecture if applicable).>
instead of >>
if you want to overwrite rather than append config files.etc/
, sbin/
, and lib/
folders.