#Requires -Version 5.1 <# .SYNOPSIS Installs superfile (terminal file manager) via winget. .DESCRIPTION Installs superfile via winget (yorukot.superfile). superfile is a modern terminal file manager with vim-style keybindings. Supported platforms: - Windows x64 (AMD64 / Intel 64bit) - Windows ARM64 Prerequisites: - winget (Windows Package Manager) — built into Windows 10 1709+ .EXAMPLE .\install-superfile.ps1 # 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" .NOTES If execution policy error occurs: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser #> [CmdletBinding()] param() Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' # Force TLS 1.2+ for HTTPS downloads (required on Windows 10 / PowerShell 5.1) [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # ──────────────────────────────────────────── # Utility functions # ──────────────────────────────────────────── 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 } # ──────────────────────────────────────────── # Step 1: Install superfile # ──────────────────────────────────────────── Info "Installing superfile (terminal file manager)..." $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/" } winget install --id yorukot.superfile --accept-package-agreements --accept-source-agreements 2>&1 | Out-Null Success "superfile installed via winget" } # ──────────────────────────────────────────── # Verify spf is available and add to PATH permanently if needed # ──────────────────────────────────────────── $spfBin = $null # 1) Try current PATH $spfCmd = Get-Command spf -ErrorAction SilentlyContinue if ($spfCmd) { $spfBin = $spfCmd.Source } # 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 } } # 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 } } } # 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 } } } 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" # 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 { Info "$spfDir already in user PATH" } } else { Warn "superfile was not found in PATH after installation." Warn "Please restart your terminal or add superfile's directory to your PATH manually." } # ──────────────────────────────────────────── # 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"