#!/bin/sh # Dotiphant installer for macOS and Linux. # # curl -fsSL https://dotiphant.com/install.sh | sh # # What it does: # 1. Installs uv (Astral's Python tool manager) if it is missing. # 2. Installs Dotiphant with `uv tool install --upgrade dotiphant`. # 3. Puts the `dotiphant` command on your PATH if it is not there yet. # 4. Starts `dotiphant open`, which continues the setup in your browser. # # Settings for testing: # DOTIPHANT_SOURCE=PATH_OR_URL install from a folder or git URL instead of PyPI # DOTIPHANT_NO_OPEN=1 print the next command instead of running it # DOTIPHANT_DRY_RUN_UV=1 if uv is missing, say what would happen and stop set -eu PACKAGE="${DOTIPHANT_SOURCE:-dotiphant}" UV_INSTALLER_URL="https://astral.sh/uv/install.sh" tmp_file="" cleanup() { if [ -n "$tmp_file" ]; then rm -f "$tmp_file"; fi; } trap cleanup EXIT trap 'exit 130' INT TERM say() { printf '\n==> %s\n' "$*"; } fail() { printf '\nError: %s\n' "$*" >&2; exit 1; } say "Checking your system" case "$(uname -s)" in Darwin) echo "macOS found." ;; Linux) echo "Linux found." ;; *) fail "This installer supports macOS and Linux only. On Windows, install uv (https://docs.astral.sh/uv/) and run: uv tool install dotiphant" ;; esac # The uv installer puts uv here. A new shell finds it; this one may not yet. PATH="$HOME/.local/bin:$PATH" if command -v uv >/dev/null 2>&1; then echo "uv is installed: $(uv --version)" else say "Installing uv, which Dotiphant uses to install itself and its own Python" echo "Source: $UV_INSTALLER_URL (the official installer from Astral)" if [ "${DOTIPHANT_DRY_RUN_UV:-}" = "1" ]; then echo "Dry run: would download that script to a temp file, then run it with sh." echo "Dry run: would then run: uv tool install --upgrade $PACKAGE" exit 0 fi tmp_file=$(mktemp) if command -v curl >/dev/null 2>&1; then curl -fsSL "$UV_INSTALLER_URL" -o "$tmp_file" elif command -v wget >/dev/null 2>&1; then wget -q -O "$tmp_file" "$UV_INSTALLER_URL" else fail "Neither curl nor wget is installed. Install one of them and run this again." fi sh "$tmp_file" command -v uv >/dev/null 2>&1 || fail "uv was installed but cannot be found. Open a new terminal and run this again." fi say "Installing Dotiphant: uv tool install --upgrade $PACKAGE" uv tool install --upgrade "$PACKAGE" bin_dir=$(uv tool dir --bin) if ! command -v dotiphant >/dev/null 2>&1; then say "Adding $bin_dir to your PATH, so new terminals find the dotiphant command" # This fails if your shell config already has it; a new terminal fixes that. if ! uv tool update-shell; then echo "Open a new terminal to use dotiphant, or add $bin_dir to your PATH." fi PATH="$bin_dir:$PATH" fi say "Done. Dotiphant $(dotiphant --version | cut -d' ' -f2) is installed." echo " Command: $bin_dir/dotiphant" echo " Program files: $(uv tool dir)/dotiphant" echo " Your archive: created during setup; 'dotiphant status' shows the folder" echo " Update: uv tool upgrade dotiphant" echo " Uninstall: uv tool uninstall dotiphant" echo " (this keeps your archive folder)" # With `curl ... | sh` the script itself arrives on stdin, so check the # output and the terminal device instead. if [ "${DOTIPHANT_NO_OPEN:-}" != "1" ] && [ -t 1 ] && (: /dev/null; then say "Starting Dotiphant. Setup continues in your browser. Press Ctrl+C to stop." dotiphant open