#!/usr/bin/env bash set -euo pipefail INSTALL_DIR="/usr/local/bin" CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/mach" BINARY="build/mach" OS="$(uname -s)" echo "Installing mach..." # Build if binary not present if [ ! -f "$BINARY" ]; then echo "Building..." make build fi # Install binary echo "Copying binary to $INSTALL_DIR..." sudo cp "$BINARY" "$INSTALL_DIR/mach" sudo chmod +x "$INSTALL_DIR/mach" # Check PATH if ! echo "$PATH" | tr ':' '\n' | grep -qx "$INSTALL_DIR"; then echo "WARNING: $INSTALL_DIR is not in your PATH. Add it to your shell profile." fi # Create config with defaults if not present if [ ! -f "$CONFIG_DIR/config.json" ]; then mkdir -p "$CONFIG_DIR" cat > "$CONFIG_DIR/config.json" <<'EOF' { "input_type": "md", "output_type": "rtf" } EOF echo "Created default config at $CONFIG_DIR/config.json" fi # Linux: create .desktop entry if [ "$OS" = "Linux" ]; then DESKTOP_DIR="$HOME/.local/share/applications" mkdir -p "$DESKTOP_DIR" cat > "$DESKTOP_DIR/mach.desktop" <