설치 명령 변경
This commit is contained in:
1 parent
f1bacee719
commit
666d7c3a9c
3 files changed
+164
-411
No files matched your search
+103
-195
@@ -1,248 +1,156 @@
|
||||
#Requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Installs superfile terminal file manager from GitHub releases.
|
||||
Installs superfile (terminal file manager) via winget.
|
||||
|
||||
.DESCRIPTION
|
||||
Auto-detects the latest release from
|
||||
https://github.com/yorukot/superfile/releases, downloads the zip
|
||||
file matching your Windows architecture, and installs it.
|
||||
Installs superfile via winget (yorukot.superfile).
|
||||
superfile is a modern terminal file manager with vim-style keybindings.
|
||||
|
||||
Supported architectures:
|
||||
- x64 (AMD64 / Intel 64bit)
|
||||
- ARM64 (Snapdragon X Elite, Qualcomm ARM, etc.)
|
||||
Supported platforms:
|
||||
- Windows x64 (AMD64 / Intel 64bit)
|
||||
- Windows ARM64
|
||||
|
||||
.PARAMETER InstallDir
|
||||
Directory to install spf.exe. Default: $env:USERPROFILE\.local\bin
|
||||
|
||||
.PARAMETER AddToPath
|
||||
Whether to permanently add InstallDir to user PATH. Default: $true
|
||||
Prerequisites:
|
||||
- winget (Windows Package Manager) — built into Windows 10 1709+
|
||||
|
||||
.EXAMPLE
|
||||
.\install-superfile.ps1
|
||||
.\install-superfile.ps1 -InstallDir "C:\tools\bin"
|
||||
.\install-superfile.ps1 -AddToPath $false
|
||||
|
||||
# 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"
|
||||
|
||||
# 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
|
||||
If execution policy error occurs:
|
||||
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string] $InstallDir = "$env:USERPROFILE\.local\bin",
|
||||
[bool] $AddToPath = $true
|
||||
)
|
||||
param()
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
# Constants
|
||||
# ────────────────────────────────────────────
|
||||
$REPO = "yorukot/superfile"
|
||||
$API_URL = "https://api.github.com/repos/$REPO/releases"
|
||||
# Force TLS 1.2+ for HTTPS downloads (required on Windows 10 / PowerShell 5.1)
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
# Utility functions
|
||||
# ────────────────────────────────────────────
|
||||
function Write-Info { param([string]$msg) Write-Host "[INFO] $msg" -ForegroundColor Cyan }
|
||||
function Write-Warn { param([string]$msg) Write-Host "[WARN] $msg" -ForegroundColor Yellow }
|
||||
function Write-Success { param([string]$msg) Write-Host "[OK] $msg" -ForegroundColor Green }
|
||||
function Write-Err { param([string]$msg) Write-Host "[ERROR] $msg" -ForegroundColor Red; exit 1 }
|
||||
function Info { Write-Host "[INFO] $args" -ForegroundColor Cyan }
|
||||
function Warn { Write-Host "[WARN] $args" -ForegroundColor Yellow }
|
||||
function Success { Write-Host "[OK] $args" -ForegroundColor Green }
|
||||
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)..."
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
# Architecture detection
|
||||
# ────────────────────────────────────────────
|
||||
function Get-Platform {
|
||||
$envArch = $env:PROCESSOR_ARCHITEW6432
|
||||
if (-not $envArch) { $envArch = $env:PROCESSOR_ARCHITECTURE }
|
||||
|
||||
switch -Regex ($envArch) {
|
||||
'^AMD64$' { return "windows-amd64" }
|
||||
'^ARM64$' { return "windows-arm64" }
|
||||
'^x86$' { Write-Err "32-bit Windows is not supported by superfile." }
|
||||
$spfCmd = Get-Command spf -ErrorAction SilentlyContinue
|
||||
if ($spfCmd) {
|
||||
$currentVer = & spf --version 2>$null
|
||||
if (-not $currentVer) { $currentVer = "unknown" }
|
||||
Info "superfile is already installed ($currentVer). Skipping installation."
|
||||
} else {
|
||||
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||
ErrExit "winget is required. Install it from the Microsoft Store or https://learn.microsoft.com/en-us/windows/package-manager/winget/"
|
||||
}
|
||||
|
||||
try {
|
||||
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
|
||||
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: $_"
|
||||
}
|
||||
winget install --id yorukot.superfile --accept-package-agreements --accept-source-agreements 2>&1 | Out-Null
|
||||
Success "superfile installed via winget"
|
||||
}
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
# Get latest stable release tag
|
||||
# Verify spf is available and add to PATH permanently if needed
|
||||
# ────────────────────────────────────────────
|
||||
function Get-LatestTag {
|
||||
Write-Info "Fetching latest release from GitHub API..."
|
||||
$spfBin = $null
|
||||
|
||||
try {
|
||||
$releases = Invoke-RestMethod -Uri $API_URL -UseBasicParsing `
|
||||
-Headers @{ 'User-Agent' = 'install-superfile-ps1' }
|
||||
} catch {
|
||||
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
|
||||
# 1) Try current PATH
|
||||
$spfCmd = Get-Command spf -ErrorAction SilentlyContinue
|
||||
if ($spfCmd) {
|
||||
$spfBin = $spfCmd.Source
|
||||
}
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
# Build download URL
|
||||
# ────────────────────────────────────────────
|
||||
function Get-DownloadUrl {
|
||||
param([string]$Tag, [string]$Platform)
|
||||
# Asset naming: superfile-windows-v1.5.0-amd64.zip
|
||||
$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
|
||||
}
|
||||
# 2) Refresh PATH from registry (winget may have added paths)
|
||||
if (-not $spfBin) {
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'User') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'Machine')
|
||||
$spfCmd = Get-Command spf -ErrorAction SilentlyContinue
|
||||
if ($spfCmd) {
|
||||
$spfBin = $spfCmd.Source
|
||||
}
|
||||
}
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
# Add to PATH (user environment variable)
|
||||
# ────────────────────────────────────────────
|
||||
function Add-ToUserPath {
|
||||
param([string]$Dir)
|
||||
|
||||
$currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
|
||||
if (-not $currentPath) { $currentPath = '' }
|
||||
$dirs = @($currentPath -split ';' | Where-Object { $_ -ne '' })
|
||||
|
||||
if ($dirs -contains $Dir) {
|
||||
Write-Info "'$Dir' is already in your PATH."
|
||||
return
|
||||
# 3) Search common locations where winget installs
|
||||
if (-not $spfBin) {
|
||||
$searchDirs = @(
|
||||
(Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Links'),
|
||||
(Join-Path $env:LOCALAPPDATA 'Programs\superfile'),
|
||||
'C:\Program Files\superfile',
|
||||
'C:\Program Files (x86)\superfile'
|
||||
)
|
||||
foreach ($dir in $searchDirs) {
|
||||
if (Test-Path $dir) {
|
||||
$candidate = Join-Path $dir 'spf.exe'
|
||||
if (Test-Path $candidate) { $spfBin = $candidate; break }
|
||||
}
|
||||
}
|
||||
|
||||
$newPath = ($dirs + $Dir) -join ';'
|
||||
[Environment]::SetEnvironmentVariable('PATH', $newPath, 'User')
|
||||
|
||||
$env:PATH = "$env:PATH;$Dir"
|
||||
|
||||
Write-Success "'$Dir' has been permanently added to user PATH."
|
||||
Write-Warn "Open a new terminal for PATH changes to take effect."
|
||||
# Recurse under WinGet/Packages for spf
|
||||
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
|
||||
if ($found) { $spfBin = $found.FullName }
|
||||
}
|
||||
}
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
# Main
|
||||
# ────────────────────────────────────────────
|
||||
function Main {
|
||||
Write-Info "===== superfile install script (Windows PowerShell) ====="
|
||||
if ($spfBin) {
|
||||
# Add spf's directory to PATH for this session
|
||||
$spfDir = Split-Path $spfBin
|
||||
if ($env:Path -notlike "*$spfDir*") {
|
||||
$env:Path = "$spfDir;$env:Path"
|
||||
Info "Added $spfDir to PATH for this session"
|
||||
}
|
||||
Success "superfile is available: $spfBin"
|
||||
|
||||
$platform = Get-Platform
|
||||
Write-Info "Detected platform: $platform"
|
||||
|
||||
$tag = Get-LatestTag
|
||||
Write-Info "Latest release: $tag"
|
||||
|
||||
$url = Get-DownloadUrl -Tag $tag -Platform $platform
|
||||
Install-Superfile -Url $url
|
||||
|
||||
if ($AddToPath) {
|
||||
Add-ToUserPath -Dir $InstallDir
|
||||
# Permanently add spf's directory to user PATH if not already there
|
||||
$userPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
if ($userPath -notlike "*$spfDir*") {
|
||||
[System.Environment]::SetEnvironmentVariable('Path', "$spfDir;$userPath", 'User')
|
||||
Success "Added $spfDir to user PATH permanently (takes effect on next login)"
|
||||
} else {
|
||||
Write-Warn "Skipping automatic PATH registration."
|
||||
Write-Warn "Add to PATH manually: $InstallDir"
|
||||
Info "$spfDir already in user PATH"
|
||||
}
|
||||
|
||||
Write-Success "All tasks completed."
|
||||
Write-Info ""
|
||||
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'."
|
||||
} else {
|
||||
Warn "superfile was not found in PATH after installation."
|
||||
Warn "Please restart your terminal or add superfile's directory to your PATH manually."
|
||||
}
|
||||
|
||||
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"
|
||||
Reference in new issue
Block a user