#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PREFIX="${HOME}/.local" LIBDIR="${PREFIX}/lib/tui" BINDIR="${PREFIX}/bin" BASHRC="${HOME}/.bashrc" MARKER="# >>> tui shell integration >>>" ENDMARKER="# <<< tui shell integration <<<" if ! command -v python3 >/dev/null 2>&1; then echo "install.sh: python3 is required" >&2 exit 1 fi if ! python3 - <<'PY' try: import yaml except ImportError: raise SystemExit(1) PY then echo "install.sh: PyYAML is required." >&2 echo "Install it with: sudo apt install python3-yaml" >&2 exit 1 fi mkdir -p "$LIBDIR" "$BINDIR" install -m 755 "$SCRIPT_DIR/tui/tui.py" "$LIBDIR/tui.py" install -m 644 "$SCRIPT_DIR/tui/tui-shell.bash" "$LIBDIR/tui-shell.bash" # Optional standalone entry point. The normal command is the Bash function # loaded from tui-shell.bash; this wrapper is useful for diagnostics. cat > "$BINDIR/tui.py" <> "$BASHRC" fi # Install an example configuration only if the user does not already have # one in the current directory. .tui files are deliberately project-local. if [[ ! -e "$HOME/.tui" && -f "$SCRIPT_DIR/tui/example.tui" ]]; then cp "$SCRIPT_DIR/tui/example.tui" "$HOME/.tui" echo "Installed example configuration: ~/.tui" fi printf '\nTUI installed to %s\n' "$LIBDIR" printf 'Bash integration installed in %s\n' "$BASHRC" printf '\nStart a new login/terminal session, or run:\n source ~/.bashrc\n\nThen:\n tui\n'