Add an installer for ripgrep + other GitHub binaries
- ID
5aa0da5- date
2022-06-03 16:40:39+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
327dddd- message
Add an installer for ripgrep + other GitHub binaries- changed files
6 files, 39 additions, 29 deletions
Changed files
_install-rust-bin (3623) → _install-github-bin (4166)
diff --git a/_install-rust-bin b/_install-github-bin
similarity index 87%
rename from _install-rust-bin
rename to _install-github-bin
index 39d0589..d2a8bca 100755
--- a/_install-rust-bin
+++ b/_install-github-bin
@@ -1,6 +1,10 @@
#!/usr/bin/env bash
# Install one of my Rust binaries from GitHub.
#
+# This was originally written to pull just my Rust binaries, but it
+# turns out it can work reasonably well for other projects. This allows
+# me to bypass Homebrew, which is generally nicer.
+#
# For my CLI tools written in Rust, I use a GitHub Action [1]
# to compile binaries and add them to a release on GitHub.
#
@@ -31,7 +35,7 @@ fi
REPO_NAME="$1"
-RELEASES_API_URL="https://api.github.com/repos/alexwlchan/$REPO_NAME/releases/latest"
+RELEASES_API_URL="https://api.github.com/repos/$REPO_NAME/releases/latest"
# Fetch the asset URL using the GitHub Releases API [2].
#
@@ -60,8 +64,12 @@ RELEASES_API_URL="https://api.github.com/repos/alexwlchan/$REPO_NAME/releases/la
#
# [2]: https://docs.github.com/en/rest/releases/releases#get-the-latest-release
#
+# Note: this will filter out ARM binaries because I'm not running on
+# Apple Silicon yet; this will need updating eventually.
+#
ASSET_URL=$(curl --silent "$RELEASES_API_URL" \
- | jq -r '.assets | .[] | select(.name | contains("darwin")) | .url'
+ | jq -r '.assets | .[] | select(.name | contains("darwin")) | select(.name | contains("arm") | not) | .url' \
+ | grep -v arm64
)
if [[ "$ASSET_URL" == "" ]]
@@ -95,20 +103,27 @@ curl \
# file, and assume that's the name of the binary.
ASSET_FILES=$(tar --list --file "asset.tar.gz")
-if (( $(echo "$ASSET_FILES" | wc -l) != 1 ))
+if [[ "$REPO_NAME" == "BurntSushi/ripgrep" ]]
then
- echo "Release asset doesn't contain exactly 1 file; not sure what to do:" >&2
- echo "$ASSET_FILES" >&2
- exit 1
-fi
+ BINARY_PATH=$(echo "$ASSET_FILES" | grep "/rg$")
+ BINARY_NAME="rg"
+else
+ if (( $(echo "$ASSET_FILES" | wc -l) != 1 ))
+ then
+ echo "Release asset doesn't contain exactly 1 file; not sure what to do:" >&2
+ echo "$ASSET_FILES" >&2
+ exit 1
+ fi
-BINARY_NAME="$(echo "$ASSET_FILES" | head -n 1)"
+ BINARY_PATH="$(echo "$ASSET_FILES" | head -n 1)"
+ BINARY_NAME="$BINARY_PATH"
+fi
# Now actually extract the binary, make it executable, and add it to the PATH.
tar --extract --gunzip --file "asset.tar.gz"
-chmod +x "$BINARY_NAME"
-mv "$BINARY_NAME" /usr/local/bin
+chmod +x "$BINARY_PATH"
+mv "$BINARY_PATH" /usr/local/bin
which "$BINARY_NAME"
"$BINARY_NAME" --version
install-dominant_colours (252) → install-dominant_colours (265)
diff --git a/install-dominant_colours b/install-dominant_colours
index bef52b9..c9413de 100755
--- a/install-dominant_colours
+++ b/install-dominant_colours
@@ -7,4 +7,4 @@
set -o errexit
set -o nounset
-_install-rust-bin dominant_colours
\ No newline at end of file
+_install-github-bin alexwlchan/dominant_colours
\ No newline at end of file
install-fzf (704) → install-fzf (196)
diff --git a/install-fzf b/install-fzf
index 58b93bf..c982f3a 100755
--- a/install-fzf
+++ b/install-fzf
@@ -1,23 +1,9 @@
#!/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).
+# See https://github.com/junegunn/fzf
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_amd64.*")))[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
+_install-github-bin junegunn/fzf
install-ripgrep (0) → install-ripgrep (228)
diff --git a/install-ripgrep b/install-ripgrep
new file mode 100755
index 0000000..7760853
--- /dev/null
+++ b/install-ripgrep
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+# This installs the latest version of ripgrep, an alternative to grep.
+#
+# See https://github.com/BurntSushi/ripgrep/releases/tag/13.0.0
+
+set -o errexit
+set -o nounset
+
+_install-github-bin BurntSushi/ripgrep
install-safari.rs (238) → install-safari.rs (251)
diff --git a/install-safari.rs b/install-safari.rs
index f929742..dfa602c 100755
--- a/install-safari.rs
+++ b/install-safari.rs
@@ -7,4 +7,4 @@
set -o errexit
set -o nounset
-_install-rust-bin safari.rs
\ No newline at end of file
+_install-github-bin alexwlchan/safari.rs
\ No newline at end of file
install-vfd (244) → install-vfd (257)
diff --git a/install-vfd b/install-vfd
index 0d6513b..944ca49 100755
--- a/install-vfd
+++ b/install-vfd
@@ -7,4 +7,4 @@
set -o errexit
set -o nounset
-_install-rust-bin books.alexwlchan.net
\ No newline at end of file
+_install-github-bin alexwlchan/books.alexwlchan.net
\ No newline at end of file