#!/bin/sh # Compiler installer (https://compiler.dev/compiler; run it with curl -fsSL https://compiler.dev/compiler/install.sh | sh, # the old address https://compiler.dev/turboterm/install.sh serves this same file). The app was # called TurboTerm, then Turbo, and is now Compiler. Free, MIT licensed. # # What this does, and nothing else: # 1. picks the build for your system (macOS Apple Silicon / Intel, Linux x64 / arm64) # 2. downloads it over HTTPS and checks its SHA-256 against the values below (aborts on mismatch) # 3. macOS: puts Compiler.app in /Applications (or ~/Applications if that isn't writable) # Linux: unpacks to ~/.local/share/turboterm, links ~/.local/bin/turboterm, adds a menu entry # 4. opens it # If the app is open, it asks first, then restarts it: windows, tabs and scrollback come back, # Claude Code / Codex resume, and other running commands come back typed at the prompt (not run). # No background services. The app sends usage counts (which pages and buttons, never commands, files or code); # Settings → Account turns them off. Never asks for sudo on macOS. On Linux it asks once, # only if your kernel blocks the sandbox Chromium normally uses (e.g. Ubuntu 24.04), to make # the bundled sandbox helper root-owned - the same thing Chrome and VS Code packages do. # # Uninstall: macOS - delete Compiler.app (or Turbo.app on 0.3.x). # Linux - rm -rf ~/.local/share/turboterm ~/.local/bin/turboterm ~/.local/share/applications/turboterm.desktop set -eu VERSION="0.4.15" # What this release's files are called: Turbo--... up to 0.3.x, Compiler--... from 0.4. Both # names keep working: the release script flips PREFIX with the SHA values, and TURBOTERM_PREFIX forces one. PREFIX="${TURBOTERM_PREFIX:-Compiler}" case "$PREFIX" in Turbo | Compiler) ;; *) printf 'TURBOTERM_PREFIX must be Turbo or Compiler\n' >&2; exit 1 ;; esac APP="$PREFIX" BASE="https://compiler-dev-downloads.s3.eu-west-2.amazonaws.com/turboterm" SHA_MAC_ARM64="2020ce8d48ea8addc87f5229a00fb315c9c8cd15bc89bff78ed83919260772cc" SHA_MAC_X64="e0a3a029cd3626eb1bd90e10cabefe971633423b2daa42663ffdff3479dbdfc4" SHA_LINUX_X64="df9ad6047cb828edc9f133f1d9a759db225a56853a177e3ce295ec16693facb2" SHA_LINUX_ARM64="89f69619ac4a412b922503a7b7818244c6c4976df687867e8026fde8fc63ee62" say() { printf '\033[1m%s\033[0m\n' "$*"; } note() { printf '%s\n' "$*"; } die() { printf '\033[31m%s\033[0m\n' "$*" >&2; exit 1; } OS="$(uname -s)" ARCH="$(uname -m)" # Under Rosetta (an Intel Terminal or shell, arch -x86_64) uname -m says x86_64 on Apple silicon, which would # install the Intel build. hw.optional.arm64 is 1 on Apple silicon even then (and missing on Intel Macs). if [ "$OS" = "Darwin" ] && [ "$(sysctl -n hw.optional.arm64 2>/dev/null)" = "1" ]; then ARCH="arm64"; fi case "$OS/$ARCH" in Darwin/arm64) FILE="$PREFIX-$VERSION-mac-arm64.zip"; SUM="$SHA_MAC_ARM64" ;; Darwin/x86_64) FILE="$PREFIX-$VERSION-mac-x64.zip"; SUM="$SHA_MAC_X64" ;; Linux/x86_64 | Linux/amd64) FILE="$PREFIX-$VERSION-linux-x64.tar.gz"; SUM="$SHA_LINUX_X64" ;; Linux/aarch64 | Linux/arm64) FILE="$PREFIX-$VERSION-linux-arm64.tar.gz"; SUM="$SHA_LINUX_ARM64" ;; *) die "$APP runs on macOS and Linux (x64, arm64). This system is $OS/$ARCH." ;; esac sha256() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | awk '{print $1}' else shasum -a 256 "$1" | awk '{print $1}'; fi } command -v curl >/dev/null 2>&1 || die "curl is needed to download $APP." TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT INT TERM say "Downloading $APP $VERSION for $OS $ARCH..." curl -fL --progress-bar "$BASE/$FILE" -o "$TMP/$FILE" || die "Download failed. Check your connection and try again." GOT="$(sha256 "$TMP/$FILE")" [ "$GOT" = "$SUM" ] || die "Checksum mismatch (got $GOT). Not installing." # The running app's main process (not its helpers), if any. Linux: match the real executable # (/proc/PID/exe), so launches through the ~/.local/bin symlink count too. macOS: the process whose # command line starts with the app's executable path. main_pid() { if [ -d /proc/self ]; then for d in /proc/[0-9]*; do HIT= [ "$(readlink "$d/exe" 2>/dev/null)" = "$1" ] && HIT=1 # Under an emulator (qemu, Rosetta) exe is the emulator; the app is argv[0] or argv[1]. [ -z "$HIT" ] && for a in $(tr '\0' '\n' < "$d/cmdline" 2>/dev/null | head -2); do [ "$(readlink -f "$a" 2>/dev/null)" = "$1" ] && HIT=1 done [ -n "$HIT" ] || continue tr '\0' ' ' < "$d/cmdline" 2>/dev/null | grep -q -- '--type=' && continue echo "${d#/proc/}" return done return fi TT_EXE="$1" ps -A -o pid= -o args= 2>/dev/null | TT_EXE="$1" awk ' { pid = $1; sub(/^ *[0-9]+ /, "") } index($0, ENVIRON["TT_EXE"]) == 1 && $0 !~ /--type=/ { print pid; exit }' } # Replacing a running app breaks it, so the app is restarted around the swap. A detached helper # does the swap after it has quit (saving its session), so this works even when the # installer itself runs inside the app and goes away with it. restart_into() { # $1 pid, $2 new build, $3 destination, $4 command to open it, $5 "clean": remove the older app names beside it (macOS) printf '%s\n' "$APP is open. To update, it restarts: your windows, tabs and scrollback come back," printf '%s\n' "Claude Code and Codex resume, and other running commands come back typed at the prompt (not run)." ANS="${TURBOTERM_RESTART:-}" if [ -z "$ANS" ]; then if [ -r /dev/tty ] && [ -w /dev/tty ]; then printf 'Restart %s now? [Y/n] ' "$APP" > /dev/tty read -r ANS < /dev/tty || ANS=n [ -z "$ANS" ] && ANS=y else ANS=n fi fi case "$ANS" in y | Y | yes | 1) ;; *) die "Not updated. Quit $APP (or answer Y) and run the installer again." ;; esac STAGE="$(mktemp -d "$(dirname "$3")/.turboterm-update.XXXXXX")" mv "$2" "$STAGE/new" if [ "$OS" = "Linux" ]; then prepare_sandbox "$STAGE/new" || die "Not updated: the sandbox helper needs to be root-owned (see above)."; fi CLEAN="" # The older names of the app (Turbo.app, TurboTerm.app) are removed once the new one is in place. if [ "${5:-}" = "clean" ]; then D="$(dirname "$3")" CLEAN="for o in \"$D/Compiler.app\" \"$D/Turbo.app\" \"$D/TurboTerm.app\"; do if [ \"\$o\" != \"$3\" ]; then rm -rf \"\$o\"; fi; done" fi cat > "$STAGE/swap.sh" </dev/null || break; sleep 0.5; done kill -0 $1 2>/dev/null && { echo "$APP did not quit; update not applied" > "$STAGE/failed"; exit 1; } if [ -e "$3" ]; then rm -rf "$3.old" && mv "$3" "$3.old"; fi mv "$STAGE/new" "$3" && rm -rf "$3.old" $CLEAN $4 rm -rf "$STAGE" SWAP nohup sh "$STAGE/swap.sh" > "$STAGE/swap.log" 2>&1 & say "Restarting $APP $VERSION..." kill -TERM "$1" exit 0 } # ------------------------------------------------------------------ macOS # The app is called Compiler (Compiler.app); 0.3.x builds were Turbo.app, and before that TurboTerm.app. Whichever # of the three is installed is replaced; settings, sessions and history are kept (they live in the same place). if [ "$OS" = "Darwin" ]; then DEST="${TURBOTERM_DEST:-/Applications}" if [ ! -w "$DEST" ]; then DEST="$HOME/Applications"; fi mkdir -p "$DEST" ditto -x -k "$TMP/$FILE" "$TMP/x" || die "Couldn't unpack the download." [ -d "$TMP/x/$APP.app" ] || die "The download didn't contain $APP.app." NEW="$DEST/$APP.app" PID="" for N in "$APP" Compiler Turbo TurboTerm; do [ -z "$PID" ] && PID="$(main_pid "$DEST/$N.app/Contents/MacOS/$N")" done if [ -n "$PID" ]; then OPEN='open "'"$NEW"'"' [ -n "${TURBOTERM_NO_OPEN:-}" ] && OPEN=: restart_into "$PID" "$TMP/x/$APP.app" "$NEW" "$OPEN" clean fi if [ -d "$NEW" ]; then say "Replacing the existing $NEW" mv "$NEW" "$TMP/old.app" fi mv "$TMP/x/$APP.app" "$NEW" for N in Compiler Turbo TurboTerm; do OLD="$DEST/$N.app" if [ "$OLD" != "$NEW" ] && [ -d "$OLD" ]; then say "Removing the old $N.app ($APP replaces it; your settings and sessions are kept)" mv "$OLD" "$TMP/older-$N.app" fi done say "Installed: $NEW" if [ -z "${TURBOTERM_NO_OPEN:-}" ]; then open "$NEW"; fi say "Done. Tip: type 'tt help' inside $APP. Remote control: $APP menu > Remote Control." exit 0 fi # ------------------------------------------------------------------ Linux DATA="${XDG_DATA_HOME:-$HOME/.local/share}" DEST="${TURBOTERM_DEST:-$DATA/turboterm}" BIN="${TURBOTERM_BIN:-$HOME/.local/bin}" mkdir -p "$TMP/x" "$BIN" "$DATA/applications" "$(dirname "$DEST")" tar -xzf "$TMP/$FILE" -C "$TMP/x" --strip-components=1 || die "Couldn't unpack the download." [ -x "$TMP/x/turboterm" ] || die "The download didn't contain the turboterm binary." # Chromium sandboxes its renderers with unprivileged user namespaces. Where the kernel blocks # those (Ubuntu 23.10+ AppArmor, some hardened kernels, containers), it needs its setuid helper # instead, which must be owned by root. We never turn the sandbox off. needs_suid() { [ "$(cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns 2>/dev/null)" = "1" ] && return 0 [ "$(cat /proc/sys/kernel/unprivileged_userns_clone 2>/dev/null)" = "0" ] && return 0 [ "$(cat /proc/sys/user/max_user_namespaces 2>/dev/null)" = "0" ] && return 0 if command -v unshare >/dev/null 2>&1 && ! unshare -U true >/dev/null 2>&1; then return 0; fi return 1 } # Make DIR/chrome-sandbox root-owned setuid if this kernel needs it. Returns 1 if that couldn't be done. prepare_sandbox() { needs_suid || return 0 SB="$1/chrome-sandbox" FIX="chown root:root '$SB' && chmod 4755 '$SB'" if [ "$(id -u)" = "0" ]; then sh -c "$FIX" && return 0 elif [ -z "${TURBOTERM_NO_SUDO:-}" ] && command -v sudo >/dev/null 2>&1; then say "Your kernel blocks the sandbox Chromium normally uses, so $APP needs its sandbox helper" say "to be owned by root. sudo will ask for your password once, to run only:" note " sudo sh -c \"$FIX\"" sudo sh -c "$FIX" && return 0 fi printf '\033[33m%s\033[0m\n' "$APP won't start until its sandbox helper is root-owned. Run:" note " sudo sh -c \"$FIX\"" return 1 } # Updating while the app is open: restart it around the swap (see restart_into). PID="$(main_pid "$DEST/turboterm")" if [ -n "$PID" ]; then OPEN='nohup "'"$DEST/turboterm"'" >/dev/null 2>&1 &' [ -n "${TURBOTERM_NO_OPEN:-}" ] && OPEN=: restart_into "$PID" "$TMP/x" "$DEST" "$OPEN" fi if [ -e "$DEST" ]; then say "Replacing the existing $DEST" mv "$DEST" "$TMP/old" fi mv "$TMP/x" "$DEST" ln -sf "$DEST/turboterm" "$BIN/turboterm" cat > "$DATA/applications/turboterm.desktop" </dev/null 2>&1 && update-desktop-database "$DATA/applications" >/dev/null 2>&1 || true SANDBOX_OK=1 prepare_sandbox "$DEST" || SANDBOX_OK=0 MISSING="$(ldd "$DEST/turboterm" 2>/dev/null | awk '/not found/{print $1}' | tr '\n' ' ')" say "Installed: $DEST" note "Command: $BIN/turboterm (also in your app menu)" case ":$PATH:" in *":$BIN:"*) ;; *) note "Note: $BIN isn't on your PATH; add it to run 'turboterm' from a shell." ;; esac if [ -n "$MISSING" ]; then printf '\033[33m%s\033[0m\n' "Missing system libraries: $MISSING" note "Debian/Ubuntu: sudo apt install libgtk-3-0 libnss3 libasound2 libgbm1 libxss1" note "Fedora: sudo dnf install gtk3 nss alsa-lib mesa-libgbm libXScrnSaver" fi if [ -z "${TURBOTERM_NO_OPEN:-}" ] && [ "$SANDBOX_OK" = "1" ] && [ -z "$MISSING" ] && [ -n "${DISPLAY:-}${WAYLAND_DISPLAY:-}" ]; then nohup "$DEST/turboterm" >/dev/null 2>&1 & fi say "Done. Tip: type 'tt help' inside $APP. Shortcuts use Ctrl+Shift (Ctrl+Shift+T new tab)."