설치 명령 변경
This commit is contained in:
1 parent
f1bacee719
commit
666d7c3a9c
3 files changed
+153
-400
No files matched your search
@@ -33,7 +33,7 @@ curl -fsSL "https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-bott
|
|||||||
**superfile:**
|
**superfile:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -fsSL "https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-superfile.sh?ref_type=heads" | bash
|
bash -c "$(curl -sLo- https://superfile.dev/install.sh)"
|
||||||
```
|
```
|
||||||
|
|
||||||
**dua:**
|
**dua:**
|
||||||
@@ -229,7 +229,7 @@ spf
|
|||||||
```
|
```
|
||||||
|
|
||||||
| 단축키 | 동작 |
|
| 단축키 | 동작 |
|
||||||
| ----------- | ------------------------ |
|
| --------------- | ------------------------- |
|
||||||
| `q` | 종료 |
|
| `q` | 종료 |
|
||||||
| `h` `j` `k` `l` | 좌/하/상/우 이동 |
|
| `h` `j` `k` `l` | 좌/하/상/우 이동 |
|
||||||
| `Enter` | 디렉토리 진입 / 파일 열기 |
|
| `Enter` | 디렉토리 진입 / 파일 열기 |
|
||||||
|
|||||||
+103
-195
@@ -1,248 +1,156 @@
|
|||||||
#Requires -Version 5.1
|
#Requires -Version 5.1
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Installs superfile terminal file manager from GitHub releases.
|
Installs superfile (terminal file manager) via winget.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Auto-detects the latest release from
|
Installs superfile via winget (yorukot.superfile).
|
||||||
https://github.com/yorukot/superfile/releases, downloads the zip
|
superfile is a modern terminal file manager with vim-style keybindings.
|
||||||
file matching your Windows architecture, and installs it.
|
|
||||||
|
|
||||||
Supported architectures:
|
Supported platforms:
|
||||||
- x64 (AMD64 / Intel 64bit)
|
- Windows x64 (AMD64 / Intel 64bit)
|
||||||
- ARM64 (Snapdragon X Elite, Qualcomm ARM, etc.)
|
- Windows ARM64
|
||||||
|
|
||||||
.PARAMETER InstallDir
|
Prerequisites:
|
||||||
Directory to install spf.exe. Default: $env:USERPROFILE\.local\bin
|
- winget (Windows Package Manager) — built into Windows 10 1709+
|
||||||
|
|
||||||
.PARAMETER AddToPath
|
|
||||||
Whether to permanently add InstallDir to user PATH. Default: $true
|
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
.\install-superfile.ps1
|
.\install-superfile.ps1
|
||||||
.\install-superfile.ps1 -InstallDir "C:\tools\bin"
|
|
||||||
.\install-superfile.ps1 -AddToPath $false
|
|
||||||
|
|
||||||
# One-liner install from remote (works on Windows 10+):
|
# One-liner install from remote (works on Windows 10+):
|
||||||
powershell -ExecutionPolicy Bypass -c "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; $t=\"$env:TEMP\install-superfile.ps1\"; iwr -useb 'https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-superfile.ps1' -OutFile $t; & $t"
|
powershell -ExecutionPolicy Bypass -c "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; $t=\"$env:TEMP\install-superfile.ps1\"; iwr -useb 'https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-superfile.ps1' -OutFile $t; & $t"
|
||||||
|
|
||||||
# With parameters:
|
|
||||||
powershell -ExecutionPolicy Bypass -c "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; $t=\"$env:TEMP\install-superfile.ps1\"; iwr -useb 'https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-superfile.ps1' -OutFile $t; & $t -InstallDir 'C:\tools\bin'"
|
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
If execution policy error occurs:
|
If execution policy error occurs:
|
||||||
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param()
|
||||||
[string] $InstallDir = "$env:USERPROFILE\.local\bin",
|
|
||||||
[bool] $AddToPath = $true
|
|
||||||
)
|
|
||||||
|
|
||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
# Force TLS 1.2+ for HTTPS downloads (required on Windows 10 / PowerShell 5.1)
|
||||||
# Constants
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
# ────────────────────────────────────────────
|
|
||||||
$REPO = "yorukot/superfile"
|
|
||||||
$API_URL = "https://api.github.com/repos/$REPO/releases"
|
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
# Utility functions
|
# Utility functions
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
function Write-Info { param([string]$msg) Write-Host "[INFO] $msg" -ForegroundColor Cyan }
|
function Info { Write-Host "[INFO] $args" -ForegroundColor Cyan }
|
||||||
function Write-Warn { param([string]$msg) Write-Host "[WARN] $msg" -ForegroundColor Yellow }
|
function Warn { Write-Host "[WARN] $args" -ForegroundColor Yellow }
|
||||||
function Write-Success { param([string]$msg) Write-Host "[OK] $msg" -ForegroundColor Green }
|
function Success { Write-Host "[OK] $args" -ForegroundColor Green }
|
||||||
function Write-Err { param([string]$msg) Write-Host "[ERROR] $msg" -ForegroundColor Red; exit 1 }
|
function ErrExit { Write-Host "[ERROR] $args" -ForegroundColor Red; exit 1 }
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
# Enforce TLS 1.2+ for HTTPS downloads (required on Windows 10 / PowerShell 5.1)
|
# Step 1: Install superfile
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
Info "Installing superfile (terminal file manager)..."
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
$spfCmd = Get-Command spf -ErrorAction SilentlyContinue
|
||||||
# Architecture detection
|
if ($spfCmd) {
|
||||||
# ────────────────────────────────────────────
|
$currentVer = & spf --version 2>$null
|
||||||
function Get-Platform {
|
if (-not $currentVer) { $currentVer = "unknown" }
|
||||||
$envArch = $env:PROCESSOR_ARCHITEW6432
|
Info "superfile is already installed ($currentVer). Skipping installation."
|
||||||
if (-not $envArch) { $envArch = $env:PROCESSOR_ARCHITECTURE }
|
} else {
|
||||||
|
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||||
switch -Regex ($envArch) {
|
ErrExit "winget is required. Install it from the Microsoft Store or https://learn.microsoft.com/en-us/windows/package-manager/winget/"
|
||||||
'^AMD64$' { return "windows-amd64" }
|
|
||||||
'^ARM64$' { return "windows-arm64" }
|
|
||||||
'^x86$' { Write-Err "32-bit Windows is not supported by superfile." }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
winget install --id yorukot.superfile --accept-package-agreements --accept-source-agreements 2>&1 | Out-Null
|
||||||
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
|
Success "superfile installed via winget"
|
||||||
switch ($arch) {
|
|
||||||
'X64' { return "windows-amd64" }
|
|
||||||
'Arm64' { return "windows-arm64" }
|
|
||||||
'X86' { Write-Err "32-bit Windows is not supported by superfile." }
|
|
||||||
default { Write-Err "Unsupported architecture: $arch" }
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
Write-Err "Failed to detect architecture: $_"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
# Get latest stable release tag
|
# Verify spf is available and add to PATH permanently if needed
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
function Get-LatestTag {
|
$spfBin = $null
|
||||||
Write-Info "Fetching latest release from GitHub API..."
|
|
||||||
|
|
||||||
try {
|
# 1) Try current PATH
|
||||||
$releases = Invoke-RestMethod -Uri $API_URL -UseBasicParsing `
|
$spfCmd = Get-Command spf -ErrorAction SilentlyContinue
|
||||||
-Headers @{ 'User-Agent' = 'install-superfile-ps1' }
|
if ($spfCmd) {
|
||||||
} catch {
|
$spfBin = $spfCmd.Source
|
||||||
Write-Err "Failed to call GitHub API: $_"
|
|
||||||
}
|
|
||||||
|
|
||||||
$latest = $releases | Where-Object { $_.prerelease -eq $false } | Select-Object -First 1
|
|
||||||
|
|
||||||
if (-not $latest) {
|
|
||||||
Write-Err "Could not find latest release."
|
|
||||||
}
|
|
||||||
|
|
||||||
return $latest.tag_name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
# 2) Refresh PATH from registry (winget may have added paths)
|
||||||
# Build download URL
|
if (-not $spfBin) {
|
||||||
# ────────────────────────────────────────────
|
$env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'User') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'Machine')
|
||||||
function Get-DownloadUrl {
|
$spfCmd = Get-Command spf -ErrorAction SilentlyContinue
|
||||||
param([string]$Tag, [string]$Platform)
|
if ($spfCmd) {
|
||||||
# Asset naming: superfile-windows-v1.5.0-amd64.zip
|
$spfBin = $spfCmd.Source
|
||||||
$version = $Tag -replace '^v', ''
|
|
||||||
$filename = "superfile-${Platform}-${Tag}.zip"
|
|
||||||
return "https://github.com/$REPO/releases/download/$Tag/$filename"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
# Download, extract & install
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
function Install-Superfile {
|
|
||||||
param([string]$Url)
|
|
||||||
|
|
||||||
$tmpDir = Join-Path $env:TEMP "superfile_install_$(Get-Random)"
|
|
||||||
New-Item -ItemType Directory -Path $tmpDir | Out-Null
|
|
||||||
|
|
||||||
try {
|
|
||||||
$zipPath = Join-Path $tmpDir "superfile.zip"
|
|
||||||
|
|
||||||
Write-Info "Downloading: $Url"
|
|
||||||
try {
|
|
||||||
$ProgressPreference = 'SilentlyContinue'
|
|
||||||
Invoke-WebRequest -Uri $Url -OutFile $zipPath -UseBasicParsing
|
|
||||||
$ProgressPreference = 'Continue'
|
|
||||||
} catch {
|
|
||||||
Write-Err "Download failed: $_"
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Info "Extracting..."
|
|
||||||
Expand-Archive -Path $zipPath -DestinationPath $tmpDir -Force
|
|
||||||
|
|
||||||
$spfExe = Get-ChildItem -Path $tmpDir -Recurse -Filter "spf.exe" |
|
|
||||||
Select-Object -First 1
|
|
||||||
if (-not $spfExe) {
|
|
||||||
Write-Err "Cannot find 'spf.exe' in the archive."
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-Path $InstallDir)) {
|
|
||||||
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
|
|
||||||
}
|
|
||||||
|
|
||||||
$destPath = Join-Path $InstallDir "spf.exe"
|
|
||||||
|
|
||||||
# Check if spf.exe is currently running (locked)
|
|
||||||
if (Test-Path $destPath) {
|
|
||||||
try {
|
|
||||||
$testStream = [System.IO.File]::Open($destPath, 'Open', 'ReadWrite', 'Delete')
|
|
||||||
$testStream.Close()
|
|
||||||
$testStream.Dispose()
|
|
||||||
} catch {
|
|
||||||
Write-Err "spf.exe is currently running. Please close superfile and run this script again."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Info "Installing: $destPath"
|
|
||||||
Copy-Item -Path $spfExe.FullName -Destination $destPath -Force
|
|
||||||
|
|
||||||
Write-Success "Installation complete!"
|
|
||||||
|
|
||||||
Write-Info "Version check:"
|
|
||||||
try {
|
|
||||||
& $destPath --version
|
|
||||||
} catch {
|
|
||||||
Write-Warn "Cannot run version check (spf may need a new terminal session to start)."
|
|
||||||
}
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (Test-Path $tmpDir) {
|
|
||||||
Remove-Item -Path $tmpDir -Recurse -Force -ErrorAction SilentlyContinue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
# 3) Search common locations where winget installs
|
||||||
# Add to PATH (user environment variable)
|
if (-not $spfBin) {
|
||||||
# ────────────────────────────────────────────
|
$searchDirs = @(
|
||||||
function Add-ToUserPath {
|
(Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Links'),
|
||||||
param([string]$Dir)
|
(Join-Path $env:LOCALAPPDATA 'Programs\superfile'),
|
||||||
|
'C:\Program Files\superfile',
|
||||||
$currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
|
'C:\Program Files (x86)\superfile'
|
||||||
if (-not $currentPath) { $currentPath = '' }
|
)
|
||||||
$dirs = @($currentPath -split ';' | Where-Object { $_ -ne '' })
|
foreach ($dir in $searchDirs) {
|
||||||
|
if (Test-Path $dir) {
|
||||||
if ($dirs -contains $Dir) {
|
$candidate = Join-Path $dir 'spf.exe'
|
||||||
Write-Info "'$Dir' is already in your PATH."
|
if (Test-Path $candidate) { $spfBin = $candidate; break }
|
||||||
return
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$newPath = ($dirs + $Dir) -join ';'
|
# Recurse under WinGet/Packages for spf
|
||||||
[Environment]::SetEnvironmentVariable('PATH', $newPath, 'User')
|
if (-not $spfBin -and (Test-Path (Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Packages'))) {
|
||||||
|
$found = Get-ChildItem -Path (Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Packages') -Recurse -Filter 'spf.exe' -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||||
$env:PATH = "$env:PATH;$Dir"
|
if ($found) { $spfBin = $found.FullName }
|
||||||
|
}
|
||||||
Write-Success "'$Dir' has been permanently added to user PATH."
|
|
||||||
Write-Warn "Open a new terminal for PATH changes to take effect."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
if ($spfBin) {
|
||||||
# Main
|
# Add spf's directory to PATH for this session
|
||||||
# ────────────────────────────────────────────
|
$spfDir = Split-Path $spfBin
|
||||||
function Main {
|
if ($env:Path -notlike "*$spfDir*") {
|
||||||
Write-Info "===== superfile install script (Windows PowerShell) ====="
|
$env:Path = "$spfDir;$env:Path"
|
||||||
|
Info "Added $spfDir to PATH for this session"
|
||||||
|
}
|
||||||
|
Success "superfile is available: $spfBin"
|
||||||
|
|
||||||
$platform = Get-Platform
|
# Permanently add spf's directory to user PATH if not already there
|
||||||
Write-Info "Detected platform: $platform"
|
$userPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
|
||||||
|
if ($userPath -notlike "*$spfDir*") {
|
||||||
$tag = Get-LatestTag
|
[System.Environment]::SetEnvironmentVariable('Path', "$spfDir;$userPath", 'User')
|
||||||
Write-Info "Latest release: $tag"
|
Success "Added $spfDir to user PATH permanently (takes effect on next login)"
|
||||||
|
|
||||||
$url = Get-DownloadUrl -Tag $tag -Platform $platform
|
|
||||||
Install-Superfile -Url $url
|
|
||||||
|
|
||||||
if ($AddToPath) {
|
|
||||||
Add-ToUserPath -Dir $InstallDir
|
|
||||||
} else {
|
} else {
|
||||||
Write-Warn "Skipping automatic PATH registration."
|
Info "$spfDir already in user PATH"
|
||||||
Write-Warn "Add to PATH manually: $InstallDir"
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
Write-Success "All tasks completed."
|
Warn "superfile was not found in PATH after installation."
|
||||||
Write-Info ""
|
Warn "Please restart your terminal or add superfile's directory to your PATH manually."
|
||||||
Write-Info "IMPORTANT: Close this terminal and open a new one to use superfile (spf)."
|
|
||||||
Write-Info "PATH changes require a new terminal session to take effect."
|
|
||||||
Write-Info ""
|
|
||||||
Write-Info "Getting started:"
|
|
||||||
Write-Info " spf - Start superfile file manager"
|
|
||||||
Write-Info " spf --help - Show help"
|
|
||||||
Write-Info ""
|
|
||||||
Write-Info "Note: The command name is 'spf', not 'superfile'."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Main
|
# ────────────────────────────────────────────
|
||||||
|
# Step 2: Post-install notes
|
||||||
|
# ────────────────────────────────────────────
|
||||||
|
Info ""
|
||||||
|
Info "=================================================="
|
||||||
|
Success "superfile installation complete!"
|
||||||
|
Info "=================================================="
|
||||||
|
if ($spfBin) {
|
||||||
|
Info ""
|
||||||
|
Info "superfile binary: $spfBin"
|
||||||
|
}
|
||||||
|
Info ""
|
||||||
|
Info "IMPORTANT: Close this terminal and open a new one to use superfile (spf)."
|
||||||
|
Info "PATH changes require a new terminal session to take effect."
|
||||||
|
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"
|
||||||
+48
-203
@@ -1,29 +1,26 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
|
|
||||||
# Downloads and installs the latest superfile from
|
# Installs superfile (terminal file manager) — https://github.com/yorukot/superfile
|
||||||
# https://github.com/yorukot/superfile/releases
|
#
|
||||||
|
# Uses the official installer on Mac/Linux:
|
||||||
|
# bash -c "$(curl -sLo- https://superfile.dev/install.sh)"
|
||||||
#
|
#
|
||||||
# Supported platforms:
|
# Supported platforms:
|
||||||
# macOS : Apple Silicon (arm64), Intel (x86_64) — via Homebrew or direct download
|
# macOS : Apple Silicon (arm64), Intel (x86_64)
|
||||||
# Linux : x86_64 (amd64), aarch64/arm64 — via direct download
|
# Linux : x86_64, aarch64/arm64
|
||||||
# Windows : Not supported — use install-superfile.ps1 (PowerShell)
|
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
# Constants
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
REPO="yorukot/superfile"
|
|
||||||
API_URL="https://api.github.com/repos/${REPO}/releases"
|
|
||||||
INSTALL_DIR="${HOME}/.local/bin"
|
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
# Utility functions (all stderr output)
|
# Utility functions (all stderr output)
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
info() { echo "[INFO] $*" >&2; }
|
info() { echo "[INFO] $*" >&2; }
|
||||||
warn() { echo "[WARN] $*" >&2; }
|
warn() { echo "[WARN] $*" >&2; }
|
||||||
error() { echo "[ERROR] $*" >&2; exit 1; }
|
error() {
|
||||||
|
echo "[ERROR] $*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
success() { echo "[OK] $*" >&2; }
|
success() { echo "[OK] $*" >&2; }
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
@@ -48,201 +45,49 @@ ensure_brew() {
|
|||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
# Check required commands
|
# Check required commands
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
for cmd in curl uname; do
|
for cmd in curl; do
|
||||||
command -v "$cmd" &>/dev/null || error "'$cmd' command is required."
|
command -v "$cmd" &>/dev/null || error "'$cmd' command is required."
|
||||||
done
|
done
|
||||||
|
|
||||||
# Fallback: use python3 if jq is not available
|
# ────────────────────────────────────────────
|
||||||
if command -v jq &>/dev/null; then
|
# Install superfile
|
||||||
_json_latest_tag() {
|
# ────────────────────────────────────────────
|
||||||
jq -r '[.[] | select(.prerelease==false)] | .[0].tag_name'
|
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
|
else
|
||||||
command -v python3 &>/dev/null || error "'jq' or 'python3' is required."
|
bash -c "$(curl -sLo- https://superfile.dev/install.sh)"
|
||||||
_json_latest_tag() {
|
success "superfile installed via official installer"
|
||||||
python3 -c "
|
fi
|
||||||
import sys, json
|
|
||||||
data = json.load(sys.stdin)
|
# Verify spf is available
|
||||||
for r in data:
|
if command -v spf &>/dev/null; then
|
||||||
if not r.get('prerelease'):
|
success "superfile is available: $(command -v spf)"
|
||||||
print(r['tag_name'])
|
else
|
||||||
break
|
warn "superfile was not found in PATH after installation. You may need to open a new terminal."
|
||||||
"
|
|
||||||
}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
# OS / Architecture detection
|
# Post-install notes
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
OS="$(uname -s)"
|
info ""
|
||||||
ARCH="$(uname -m)"
|
info "=================================================="
|
||||||
|
success "superfile installation complete!"
|
||||||
case "$OS" in
|
info "=================================================="
|
||||||
Darwin | Linux) ;;
|
info ""
|
||||||
*)
|
info "Getting started:"
|
||||||
error "Unsupported OS: $OS. This script only supports macOS and Linux."
|
info " spf - Start superfile file manager"
|
||||||
;;
|
info " spf --help - Show help"
|
||||||
esac
|
info ""
|
||||||
|
info "Note: The command name is 'spf', not 'superfile'."
|
||||||
# Returns: "<platform>:<archive_format>"
|
info ""
|
||||||
detect_platform() {
|
info "Key bindings (vim-style):"
|
||||||
case "$OS" in
|
info " h/j/k/l - Left/Down/Up/Right"
|
||||||
Darwin)
|
info " Enter - Open directory / file"
|
||||||
case "$ARCH" in
|
info " y - Yank (copy)"
|
||||||
arm64) echo "darwin-arm64:tar.gz" ;;
|
info " d - Delete"
|
||||||
x86_64) echo "darwin-amd64:tar.gz" ;;
|
info " r - Rename"
|
||||||
*) error "Unsupported macOS architecture: $ARCH" ;;
|
info " / - Search"
|
||||||
esac
|
info " Tab - Switch panel"
|
||||||
;;
|
|
||||||
Linux)
|
|
||||||
case "$ARCH" in
|
|
||||||
x86_64|amd64) echo "linux-amd64:tar.gz" ;;
|
|
||||||
aarch64|arm64) echo "linux-arm64:tar.gz" ;;
|
|
||||||
*) error "Unsupported Linux architecture: $ARCH" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
# Get latest stable release tag
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
get_latest_tag() {
|
|
||||||
info "Fetching latest release from GitHub API..."
|
|
||||||
|
|
||||||
local releases
|
|
||||||
releases="$(curl -fsSL "${API_URL}")" || error "Failed to call GitHub API."
|
|
||||||
|
|
||||||
local tag
|
|
||||||
tag="$(echo "$releases" | _json_latest_tag)"
|
|
||||||
|
|
||||||
[[ -z "$tag" || "$tag" == "null" ]] && error "Could not find latest release tag."
|
|
||||||
echo "$tag"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
# Build download URL
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
# Asset naming: superfile-{os}-{tag_version}-{arch}.tar.gz
|
|
||||||
build_download_url() {
|
|
||||||
local tag="$1"
|
|
||||||
local platform="$2" # e.g. darwin-arm64
|
|
||||||
local ext="$3" # tar.gz | zip
|
|
||||||
local version="${tag#v}"
|
|
||||||
|
|
||||||
local filename="superfile-${platform}-${tag}.${ext}"
|
|
||||||
echo "https://github.com/${REPO}/releases/download/${tag}/${filename}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
# Download, extract & install
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
download_and_install() {
|
|
||||||
local url="$1"
|
|
||||||
local ext="$2"
|
|
||||||
|
|
||||||
local tmpdir
|
|
||||||
tmpdir="$(mktemp -d)"
|
|
||||||
trap '[[ -d "${tmpdir:-}" ]] && rm -rf "$tmpdir"' EXIT
|
|
||||||
|
|
||||||
local filename
|
|
||||||
filename="${url##*/}"
|
|
||||||
|
|
||||||
info "Downloading: $url"
|
|
||||||
curl -fsSL --progress-bar -o "${tmpdir}/${filename}" "$url" \
|
|
||||||
|| error "Download failed: $url"
|
|
||||||
|
|
||||||
info "Extracting..."
|
|
||||||
case "$ext" in
|
|
||||||
tar.gz)
|
|
||||||
command -v tar &>/dev/null || error "'tar' command is required."
|
|
||||||
tar -xzf "${tmpdir}/${filename}" -C "$tmpdir"
|
|
||||||
;;
|
|
||||||
zip)
|
|
||||||
if command -v unzip &>/dev/null; then
|
|
||||||
unzip -q "${tmpdir}/${filename}" -d "$tmpdir"
|
|
||||||
elif command -v tar &>/dev/null; then
|
|
||||||
tar -xf "${tmpdir}/${filename}" -C "$tmpdir"
|
|
||||||
else
|
|
||||||
error "'unzip' or 'tar' is required."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
error "Unknown archive format: $ext"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Binary name
|
|
||||||
local bin_name="spf"
|
|
||||||
[[ "$OS" == "MINGW"* || "$OS" == "MSYS"* || "$OS" == "CYGWIN"* ]] && bin_name="spf.exe"
|
|
||||||
|
|
||||||
local bin_src
|
|
||||||
bin_src="$(find "$tmpdir" -maxdepth 3 -type f -name "$bin_name" | head -1)"
|
|
||||||
[[ -z "$bin_src" ]] && error "Cannot find '$bin_name' in the archive."
|
|
||||||
|
|
||||||
# Create install directory
|
|
||||||
mkdir -p "$INSTALL_DIR"
|
|
||||||
|
|
||||||
local install_path="${INSTALL_DIR}/${bin_name}"
|
|
||||||
info "Installing: ${install_path}"
|
|
||||||
cp "$bin_src" "$install_path"
|
|
||||||
chmod +x "$install_path"
|
|
||||||
|
|
||||||
success "Installation complete!"
|
|
||||||
info "Version check:"
|
|
||||||
"$install_path" --version || true
|
|
||||||
|
|
||||||
# PATH instructions
|
|
||||||
if ! echo ":${PATH}:" | grep -q ":${INSTALL_DIR}:"; then
|
|
||||||
warn "'${INSTALL_DIR}' is not in your PATH."
|
|
||||||
warn "Add this line to your ~/.bashrc or ~/.zshrc:"
|
|
||||||
warn " export PATH=\"\$HOME/.local/bin:\$PATH\""
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
# Main
|
|
||||||
# ────────────────────────────────────────────
|
|
||||||
main() {
|
|
||||||
local platform_info platform ext tag url
|
|
||||||
|
|
||||||
platform_info="$(detect_platform)"
|
|
||||||
platform="${platform_info%%:*}"
|
|
||||||
ext="${platform_info##*:}"
|
|
||||||
|
|
||||||
info "Detected platform: $platform (format: $ext)"
|
|
||||||
|
|
||||||
# macOS: try Homebrew first
|
|
||||||
if [[ "$OS" == "Darwin" ]]; then
|
|
||||||
if command -v spf &>/dev/null; then
|
|
||||||
local current_ver
|
|
||||||
current_ver="$(spf --version 2>/dev/null || echo 'unknown')"
|
|
||||||
info "superfile is already installed ($current_ver). Skipping installation."
|
|
||||||
else
|
|
||||||
ensure_brew
|
|
||||||
brew install superfile
|
|
||||||
success "superfile installed via Homebrew"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if command -v spf &>/dev/null; then
|
|
||||||
local current_ver
|
|
||||||
current_ver="$(spf --version 2>/dev/null || echo 'unknown')"
|
|
||||||
info "superfile is already installed ($current_ver). Skipping installation."
|
|
||||||
else
|
|
||||||
tag="$(get_latest_tag)"
|
|
||||||
info "Latest release: $tag"
|
|
||||||
|
|
||||||
url="$(build_download_url "$tag" "$platform" "$ext")"
|
|
||||||
download_and_install "$url" "$ext"
|
|
||||||
fi
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
Reference in new issue
Block a user