Files
install-sh/install-superfile.sh
T
2026-05-14 08:51:40 +09:00

94 lines
3.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# shellcheck disable=SC2086
# Installs superfile (terminal file manager) — https://github.com/yorukot/superfile
#
# Uses the official installer on Mac/Linux:
# bash -c "$(curl -sLo- https://superfile.dev/install.sh)"
#
# Supported platforms:
# macOS : Apple Silicon (arm64), Intel (x86_64)
# Linux : x86_64, aarch64/arm64
set -euo pipefail
# ────────────────────────────────────────────
# Utility functions (all stderr output)
# ────────────────────────────────────────────
info() { echo "[INFO] $*" >&2; }
warn() { echo "[WARN] $*" >&2; }
error() {
echo "[ERROR] $*" >&2
exit 1
}
success() { echo "[OK] $*" >&2; }
# ────────────────────────────────────────────
# Ensure Homebrew is available on macOS
# ────────────────────────────────────────────
ensure_brew() {
if command -v brew &>/dev/null; then
return 0
fi
info "Homebrew is not installed. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [ -d /opt/homebrew/bin ]; then
export PATH="/opt/homebrew/bin:$PATH"
fi
if [ -d /usr/local/bin ]; then
export PATH="/usr/local/bin:$PATH"
fi
command -v brew &>/dev/null || error "Homebrew installation failed. Install it manually: https://brew.sh/"
success "Homebrew installed"
}
# ────────────────────────────────────────────
# Check required commands
# ────────────────────────────────────────────
for cmd in curl; do
command -v "$cmd" &>/dev/null || error "'$cmd' command is required."
done
# ────────────────────────────────────────────
# Install superfile
# ────────────────────────────────────────────
info "Installing superfile (terminal file manager)..."
if command -v spf &>/dev/null; then
CURRENT_VER="$(spf --version 2>/dev/null || echo 'unknown')"
info "superfile is already installed ($CURRENT_VER). Skipping installation."
else
bash -c "$(curl -sLo- https://superfile.dev/install.sh)"
success "superfile installed via official installer"
fi
# Verify spf is available
if command -v spf &>/dev/null; then
success "superfile is available: $(command -v spf)"
else
warn "superfile was not found in PATH after installation. You may need to open a new terminal."
fi
# ────────────────────────────────────────────
# Post-install notes
# ────────────────────────────────────────────
info ""
info "=================================================="
success "superfile installation complete!"
info "=================================================="
info ""
info "Getting started:"
info " spf - Start superfile file manager"
info " spf --help - Show help"
info ""
info "Note: The command name is 'spf', not 'superfile'."
info ""
info "Key bindings (vim-style):"
info " h/j/k/l - Left/Down/Up/Right"
info " Enter - Open directory / file"
info " y - Yank (copy)"
info " d - Delete"
info " r - Rename"
info " / - Search"
info " Tab - Switch panel"