brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: gh release download with a pattern grabs only the release file you need

CLI
~/tips/tip-cli-gh-release-download-pattern

gh release download -R cli/cli --pattern '*linux_amd64.tar.gz' -D /tmp/gh

Downloads only the matching assets of a release, without the browser.

Release pages often list twenty files for every platform. In a setup script you want one of them, and you want the latest version without hard coding it.

Pick the repository with -R and the files with a glob:

gh release download -R cli/cli --pattern '*linux_amd64.tar.gz' -D /tmp/gh

Without a tag it takes the latest release. Give a tag as the first argument to pin a version:

gh release download v2.60.0 -R cli/cli -p '*checksums.txt' -p '*macOS_arm64.zip'

-p can be repeated, which I find handy to fetch the binary and the checksum file in one go. -D sets the target folder. --archive=zip or --archive=tar.gz downloads the source code archive instead of the assets.

Because it uses your gh login, it also works for releases in private repositories, which is awkward with plain curl.

Quote the pattern, or your own shell expands the asterisk against local files first and the command gets the wrong argument. If a file with the same name is already there, choose --clobber to overwrite it or --skip-existing to keep it. And the latest release is whatever the project marked as latest, so a prerelease you see at the top of the page may not be what you get.

Further reading: gh release download (GitHub CLI manual)

Going deeper: Moving on from hdtv: how to export your TV show list to Trakt.tv

More CLI tips printf 'GET /\r\n' | hexdump -C hexdump -C -s 512 -n 64 disk.img wget --limit-rate=2m https://example.com/big-file.iso wget --spider https://example.com/file.zip rg 'apiKey' -g '!*.min.js' -g '!package-lock.json' All CLI tips (46) All topics

Link