#!/usr/bin/env bash

set -euo pipefail

if ! command -v mise >/dev/null 2>&1; then
	curl -fsSL https://mise.run | sh
fi

export PATH="$HOME/.local/bin:$HOME/.local/share/mise/shims:$PATH"

mise trust "$PWD/mise.toml"
mise install

profile="$HOME/.profile"
shims_path='export PATH="$HOME/.local/bin:$HOME/.local/share/mise/shims:$PATH"'
if ! grep -Fqx "$shims_path" "$profile" 2>/dev/null; then
	printf '\n%s\n' "$shims_path" >> "$profile"
fi
