#!/usr/bin/env bash # install.sh -- installs sl0ppi on this machine. Ships inside the tarball. # # ./install.sh [--prefix DIR] [--force-config] [--dry-run] [--uninstall] # # Defaults to a per-user install under ~/.local, touching nothing outside: # # $PREFIX/bin/{sl0ppi,sl0ppij,pi,pir} (sl0ppi and pi run on the bundled bun) # $PREFIX/libexec/sl0ppi/ bundled bun + pi # $PREFIX/share/sl0ppi/ config templates, layouts, themes, plugins # ~/.config/sl0ppij/ live config (never clobbered without --force-config) # ~/.pi/agent/extensions/ pi extensions # # The bundle is self-contained: no system node, npm or rust needed. set -euo pipefail PREFIX="${PREFIX:-$HOME/.local}" CONFIG_DIR="${SL0PPIJ_CONFIG_DIR:-$HOME/.config/sl0ppij}" PI_EXT_DIR="${PI_EXT_DIR:-$HOME/.pi/agent/extensions}" force_config=0 dry_run=0 uninstall=0 while [ $# -gt 0 ]; do case "$1" in --prefix) PREFIX="$2"; shift 2 ;; --prefix=*) PREFIX="${1#*=}"; shift ;; --force-config) force_config=1; shift ;; -n|--dry-run) dry_run=1; shift ;; --uninstall) uninstall=1; shift ;; -h|--help) sed -n '2,17p' "$0" | sed 's/^# \?//'; exit 0 ;; *) echo "install.sh: unknown argument '$1'" >&2; exit 2 ;; esac done SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" VERSION="$(cat "$SRC/VERSION")" LIBEXEC="$PREFIX/libexec/sl0ppi" SHARE="$PREFIX/share/sl0ppi" say() { printf '\033[36m==>\033[0m %s\n' "$*"; } warn() { printf '\033[33mwarn:\033[0m %s\n' "$*" >&2; } run() { if [ "$dry_run" = 1 ]; then echo " would: $*"; else "$@"; fi; } if [ "$uninstall" = 1 ]; then say "removing sl0ppi from $PREFIX (config and pi extensions are left alone)" for f in sl0ppi sl0ppij pi pir; do run rm -f "$PREFIX/bin/$f"; done run rm -rf "$LIBEXEC" "$SHARE" say "done. Config still at $CONFIG_DIR" exit 0 fi say "installing sl0ppi $VERSION -> $PREFIX" # --- binaries and payload -------------------------------------------------- run mkdir -p "$PREFIX/bin" "$LIBEXEC" "$SHARE" run install -m755 "$SRC/bin/sl0ppij" "$PREFIX/bin/sl0ppij" run install -m755 "$SRC/bin/pir" "$PREFIX/bin/pir" run install -m755 "$SRC/libexec/bun" "$LIBEXEC/bun" run install -m644 "$SRC/libexec/sl0ppi.js" "$LIBEXEC/sl0ppi.js" run rm -rf "$LIBEXEC/pi" run cp -a "$SRC/libexec/pi" "$LIBEXEC/pi" run rm -rf "$SHARE/sl0ppij" "$SHARE/pi-ext" run cp -a "$SRC/share/sl0ppij" "$SRC/share/pi-ext" "$SHARE/" run install -m644 "$SRC/MANIFEST" "$SHARE/MANIFEST" # pi and sl0ppi are generated wrappers: bundled runtime, no system node. if [ "$dry_run" = 1 ]; then echo " would: generate $PREFIX/bin/pi and $PREFIX/bin/sl0ppi wrappers" else cat > "$PREFIX/bin/pi" < "$PREFIX/bin/sl0ppi" </dev/null 2>&1; then say "note: a stock zellij is also installed. That is fine -- sl0ppij keeps its" echo " own config dir, cache dir, socket dir and sessions, and the two can" echo " run at the same time." fi say "start with: sl0ppi up (in a directory that holds your projects)" echo " sl0ppi doctor check this installation" echo " sl0ppi init make the current directory a project" echo " sl0ppij the multiplexer on its own, if you prefer"