#!/usr/bin/env bash

# omarchy:summary=Install dotstow, the stow-based dotfiles manager
# omarchy:requires-sudo=true

# Based: stow from apt or brew, then dotstow's own installer into
# /usr/local, or into the Homebrew prefix on a Mac, where /usr/local is not
# the user's to write.

set -eo pipefail

echo "Installing dotstow..."
omarchy-pkg-add stow

prefix=/usr/local
as_root=sudo
if [[ $(omarchy-os) == darwin ]]; then
  prefix=$(brew --prefix)
  as_root=
fi

if [[ ! -x $prefix/bin/dotstow ]]; then
  curl -fsSL https://gitlab.com/bitspur/community/dotstow/-/raw/main/install.sh | $as_root env PREFIX="$prefix" sh
fi
