#!/bin/sh # SiftMac's one-line install: curl -fsSL https://siftmac.com/install.sh | sh # # Downloads SiftMac with curl, copies it into Applications and opens it. macOS only checks apps a # browser marked as downloaded from the internet, and curl doesn't mark them, so SiftMac opens # straight away instead of stopping at "SiftMac" Not Opened. # # It touches nothing but SiftMac.app and a temporary folder, which it deletes at the end. # Everything runs inside main(), so a download of this script that breaks off halfway runs nothing. set -eu main() { say() { printf '%s\n' "$*"; } fail() { printf 'SiftMac: %s\n' "$*" >&2; exit 1; } [ "$(uname -s)" = Darwin ] || fail "SiftMac runs on macOS only." version=$(sw_vers -productVersion) [ "${version%%.*}" -ge 14 ] || fail "SiftMac needs macOS 14 or later. This Mac has macOS $version." if pgrep -xq SiftMac; then fail "SiftMac is open. Quit it (SiftMac › Quit SiftMac), then run this again."; fi # Applications if this account may write there, as admin accounts can; otherwise ~/Applications. dir=/Applications [ -w "$dir" ] || dir="$HOME/Applications" mkdir -p "$dir" tmp=$(mktemp -d "${TMPDIR:-/tmp}/siftmac.XXXXXX") trap 'hdiutil detach -quiet "$tmp/mnt" 2>/dev/null || true; rm -rf "$tmp"' EXIT trap 'exit 130' INT TERM say "Downloading SiftMac…" curl -fL --progress-bar -A "SiftMac-Install/1 (macOS $version)" -o "$tmp/SiftMac.dmg" https://siftmac.com/SiftMac.dmg \ || fail "Couldn’t download SiftMac. Check your connection, then run this again." mkdir "$tmp/mnt" hdiutil attach -quiet -nobrowse -readonly -noautoopen -mountpoint "$tmp/mnt" "$tmp/SiftMac.dmg" \ || fail "Couldn’t open the download. Run this again." [ -d "$tmp/mnt/SiftMac.app" ] || fail "The download has no SiftMac.app in it. Try again, or get it from siftmac.com/download." say "Installing in $dir…" rm -rf "$dir/SiftMac.app" ditto "$tmp/mnt/SiftMac.app" "$dir/SiftMac.app" # Nothing above marks it as downloaded; this makes sure an older copy's mark doesn't come along. xattr -dr com.apple.quarantine "$dir/SiftMac.app" 2>/dev/null || true say "Done. Opening SiftMac." open "$dir/SiftMac.app" } main "$@"