Skip to main content

Add a script for installing fzf

ID
fa17795
date
2022-05-01 18:51:23+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
e8ddd7f
message
Add a script for installing fzf
changed files
1 file, 23 additions

Changed files

install-fzf (0) → install-fzf (704)

diff --git a/install-fzf b/install-fzf
new file mode 100755
index 0000000..39ef814
--- /dev/null
+++ b/install-fzf
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+# This installs the latest version of fzf, a command-line fuzzy finder
+# (https://github.com/junegunn/fzf).
+#
+# Because fzf can be downloaded and installed as a single binary, I do that rather
+# than dealing with Homebrew (which is both slower and more likely to break something
+# completely unrelated).
+
+set -o errexit
+set -o nounset
+
+DOWNLOAD_URL=$(curl --silent 'https://api.github.com/repos/junegunn/fzf/releases/latest' \
+  | jq -r ' .assets | map(.browser_download_url) | map(select(test(".*darwin_arm64.*")))[0]'
+)
+
+cd $(mktemp -d)
+
+# The --location flag means we follow redirects
+curl --location "$DOWNLOAD_URL" > fzf.zip
+unzip fzf.zip
+
+chmod +x fzf
+mv fzf /usr/local/bin/fzf