#!/usr/bin/env bash set -euo pipefail brewLocation="charmbracelet/tap/crush" npmLocation="@charmland/crush" local_bin="${HOME}/.bin/crush" go_crush="${GOBIN:-${GOPATH:-$HOME/go}/bin}/crush" is_linux=false if [[ "$(uname -s)" == "Linux" ]]; then is_linux=true fi if [[ "$is_linux" == true ]]; then npm_check_cmd="sudo npm list -g $npmLocation" npm_uninstall_cmd="sudo npm uninstall -g $npmLocation" else npm_check_cmd="npm list -g $npmLocation" npm_uninstall_cmd="npm uninstall -g $npmLocation" fi found=0 if command -v brew >/dev/null 2>&1 && brew list "$brewLocation" >/dev/null 2>&1; then echo "Found Crush via Homebrew" found=1 fi if command -v npm >/dev/null 2>&1 && eval "$npm_check_cmd" >/dev/null 2>&1; then echo "Found Crush via NPM" found=1 fi if [[ -x "$local_bin" ]]; then echo "Found local Crush binary at $local_bin" found=1 fi if [[ -x "$go_crush" ]]; then echo "Found Crush Go binary at $go_crush" found=1 fi if command -v rpm >/dev/null 2>&1 && rpm -q crush >/dev/null 2>&1; then echo "Found Crush via DNF" found=1 fi if [[ $found -eq 0 ]]; then echo "Crush is not installed" exit 1 fi if command -v brew >/dev/null 2>&1 && brew list "$brewLocation" >/dev/null 2>&1; then echo "Uninstalling via Homebrew..." brew uninstall "$brewLocation" fi if command -v npm >/dev/null 2>&1 && eval "$npm_check_cmd" >/dev/null 2>&1; then echo "Uninstalling via NPM..." eval "$npm_uninstall_cmd" fi if [[ -x "$local_bin" ]]; then echo "Removing local binary at $local_bin..." rm -f "$local_bin" fi if [[ -x "$go_crush" ]]; then echo "Removing Go binary at $go_crush..." rm -f "$go_crush" fi if command -v rpm >/dev/null 2>&1 && rpm -q crush >/dev/null 2>&1; then echo "Uninstalling via DNF..." sudo dnf remove -y crush fi