fix: install.sh falls back to ~/.local/bin with PATH hint, redesign terminal section as interactive TUI simulation

This commit is contained in:
noah
2026-03-09 23:01:59 +01:00
parent b57b843459
commit b47399335a
2 changed files with 247 additions and 41 deletions
+68 -12
View File
@@ -5,7 +5,6 @@ set -e
REPO="noauf/Transmute"
BINARY="transmute"
INSTALL_DIR="/usr/local/bin"
# Detect OS
OS="$(uname -s)"
@@ -39,19 +38,20 @@ fi
ASSET="${BINARY}-${OS}-${ARCH}.${EXT}"
echo "Transmute CLI installer"
echo "======================"
echo ""
echo " Transmute CLI installer"
echo " ======================"
echo ""
echo " OS: $OS"
echo " Arch: $ARCH"
echo ""
# Get latest release tag
echo "Fetching latest release..."
echo " Fetching latest release..."
TAG=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
if [ -z "$TAG" ]; then
echo "Error: could not determine latest release"
echo " Error: could not determine latest release"
exit 1
fi
@@ -84,26 +84,82 @@ elif [ -f "${TMP_DIR}/${BINARY}-${OS}-${ARCH}/${BINARY}" ]; then
fi
if [ -z "$BIN_PATH" ]; then
echo "Error: could not find ${BINARY} binary in archive"
echo " Error: could not find ${BINARY} binary in archive"
exit 1
fi
chmod +x "$BIN_PATH"
# Install
echo " Installing to ${INSTALL_DIR}/${BINARY}..."
if [ -w "$INSTALL_DIR" ]; then
# Determine install directory — try in order of preference
INSTALL_DIR=""
NEEDS_PATH_HINT=""
if [ -w "/usr/local/bin" ]; then
INSTALL_DIR="/usr/local/bin"
elif command -v sudo >/dev/null 2>&1; then
# Try sudo to /usr/local/bin
echo " Installing to /usr/local/bin (requires sudo)..."
if sudo mv "$BIN_PATH" "/usr/local/bin/${BINARY}" 2>/dev/null; then
sudo chmod +x "/usr/local/bin/${BINARY}"
INSTALL_DIR="/usr/local/bin"
fi
fi
# Fallback: ~/.local/bin (no sudo needed)
if [ -z "$INSTALL_DIR" ]; then
INSTALL_DIR="${HOME}/.local/bin"
mkdir -p "$INSTALL_DIR"
mv "$BIN_PATH" "${INSTALL_DIR}/${BINARY}"
chmod +x "${INSTALL_DIR}/${BINARY}"
# Check if ~/.local/bin is in PATH
case ":${PATH}:" in
*":${INSTALL_DIR}:"*) ;;
*)
NEEDS_PATH_HINT="true"
;;
esac
else
echo " (requires sudo)"
sudo mv "$BIN_PATH" "${INSTALL_DIR}/${BINARY}"
if [ -f "$BIN_PATH" ]; then
mv "$BIN_PATH" "${INSTALL_DIR}/${BINARY}"
chmod +x "${INSTALL_DIR}/${BINARY}"
fi
fi
echo ""
echo " Installed transmute $TAG to ${INSTALL_DIR}/${BINARY}"
echo ""
# If we installed to a dir not in PATH, tell the user how to fix it
if [ "$NEEDS_PATH_HINT" = "true" ]; then
SHELL_NAME="$(basename "$SHELL")"
case "$SHELL_NAME" in
zsh) RC_FILE="~/.zshrc" ;;
bash) RC_FILE="~/.bashrc" ;;
fish) RC_FILE="~/.config/fish/config.fish" ;;
*) RC_FILE="your shell config" ;;
esac
echo " To make it globally available, add ~/.local/bin to your PATH:"
echo ""
if [ "$SHELL_NAME" = "fish" ]; then
echo " fish_add_path ${INSTALL_DIR}"
else
echo " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ${RC_FILE}"
fi
echo ""
echo " Then restart your terminal, or run:"
echo ""
if [ "$SHELL_NAME" = "fish" ]; then
echo " fish_add_path ${INSTALL_DIR}"
else
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
fi
echo ""
fi
echo " Get started:"
echo " transmute *.png Convert all PNGs"
echo " transmute ./files/ Convert all files in a directory"
echo " transmute ./photos/ Convert all files in a directory"
echo " transmute --help Show all options"
echo ""