Skip to content
Myr

install.ps1

This file

Path

install.ps1

65 lines · 1.8 KiB

Last changed by

landed by oscabrielc0a193e

History of this file

Take it

The walk stopped after 200 commits: lines older than 76efddd point at it.

1$version="0.74.5"

bash: shift-delete to delete history entries during CTRL-RJunegunn Choibefore adoption76efddd

lines 2–65why, one step back
2
3$fzf_base=Split-Path -Parent $MyInvocation.MyCommand.Definition45function check_binary () {6 Write-Host " - Checking fzf executable ... " -NoNewline7 $output=cmd /c $fzf_base\bin\fzf.exe --version 2>&18 if (-not $?) {9 Write-Host "Error: $output"10 $binary_error="Invalid binary"11 } else {12 $output=(-Split $output)[0]13 if ($version -ne $output) {14 Write-Host "$output != $version"15 $binary_error="Invalid version"16 } else {17 Write-Host "$output"18 $binary_error=""19 return 120 }21 }22 Remove-Item "$fzf_base\bin\fzf.exe"23 return 024}2526function download {27 param($file)28 Write-Host "Downloading bin/fzf ..."29 if (Test-Path "$fzf_base\bin\fzf.exe") {30 Write-Host " - Already exists"31 if (check_binary) {32 return33 }34 }35 if (-not (Test-Path "$fzf_base\bin")) {36 md "$fzf_base\bin"37 }38 if (-not $?) {39 $binary_error="Failed to create bin directory"40 return41 }42 cd "$fzf_base\bin"43 $url="https://github.com/junegunn/fzf/releases/download/v$version/$file"44 $temp=$env:TMP + "\fzf.zip"45 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls1246 if ($PSVersionTable.PSVersion.Major -ge 3) {47 Invoke-WebRequest -Uri $url -OutFile $temp48 } else {49 (New-Object Net.WebClient).DownloadFile($url, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$temp"))50 }51 if ($?) {52 (Microsoft.PowerShell.Archive\Expand-Archive -Path $temp -DestinationPath .); (Remove-Item $temp)53 } else {54 $binary_error="Failed to download with powershell"55 }56 if (-not (Test-Path fzf.exe)) {57 $binary_error="Failed to download $file"58 return59 }60 echo y | icacls $fzf_base\bin\fzf.exe /grant Administrator:F ; check_binary >$null61}6263download "fzf-$version-windows_amd64.zip"6465Write-Host 'For more information, see: https://github.com/junegunn/fzf'