{"id":20162582,"url":"https://github.com/zdharma-continuum/zinit-annex-readurl","last_synced_at":"2025-04-10T00:35:54.834Z","repository":{"id":45974360,"uuid":"423395427","full_name":"zdharma-continuum/zinit-annex-readurl","owner":"zdharma-continuum","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-21T06:03:39.000Z","size":72,"stargazers_count":7,"open_issues_count":4,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T02:21:50.863Z","etag":null,"topics":["zinit","zinit-annex","zsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zdharma-continuum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-11-01T08:46:45.000Z","updated_at":"2024-11-14T14:16:55.000Z","dependencies_parsed_at":"2024-04-16T14:36:27.392Z","dependency_job_id":"4d72ba7e-067c-43be-ae04-463cd9bb37be","html_url":"https://github.com/zdharma-continuum/zinit-annex-readurl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdharma-continuum%2Fzinit-annex-readurl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdharma-continuum%2Fzinit-annex-readurl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdharma-continuum%2Fzinit-annex-readurl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdharma-continuum%2Fzinit-annex-readurl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zdharma-continuum","download_url":"https://codeload.github.com/zdharma-continuum/zinit-annex-readurl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247749955,"owners_count":20989714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["zinit","zinit-annex","zsh"],"created_at":"2024-11-14T00:25:50.360Z","updated_at":"2025-04-10T00:35:54.811Z","avatar_url":"https://github.com/zdharma-continuum.png","language":"Shell","funding_links":[],"categories":["Plugins"],"sub_categories":["ZSH on Windows"],"readme":"# zinit-annex-readurl\u003ca name=\"zinit-annex-readurl\"\u003e\u003c/a\u003e\n\n\u003c!-- mdformat-toc start --slug=github --maxlevel=6 --minlevel=2 --\u003e\n\n- [Usage](#usage)\n- [Intermediate Download Page](#intermediate-download-page)\n- [Skipping `dlink''` Ice](#skipping-dlink-ice)\n- [Sorting matched URLs/versions](#sorting-matched-urlsversions)\n- [Filtering The Matched URLs](#filtering-the-matched-urls)\n- [Examples](#examples)\n\n\u003c!-- mdformat-toc end --\u003e\n\n## Usage\u003ca name=\"usage\"\u003e\u003c/a\u003e\n\nLoad as a regular plugin via:\n\n```zsh\nzinit light zdharma-continuum/z-a-readurl\n```\n\nAfter executing the above command (possibly via `zshrc`), it's then possible to use the `dlink''` and `dlink0''` ices\nand the special `as'readurl|…'` value of the `as''` ice.\n\nThis Zinit extension allows to automatically download the newest version of a file to which the URL is hosted on a\nwebpage.\n\nThe annex provides:\n\n1. Two new ices: `dlink''` and `dlink0''`.\n1. A handling of the special values of the `as''` ice, i.e.: of `as'readurl'`, `as'readurl|command'`, etc.\n\n\u003e **Note**: The annex works only with snippets, not plugins.\n\nIt works as follows:\n\n- invoke `snippet` (or pass the `http://…` address using the `for` syntax) on the web-page that hosts the URL to the\n  file to download,\n- provide `dlink''` ice with the expected file-download URL, replacing the version with the `%VERSION%` keyword,\n- also, provide `as''` ice with one of the following values: `readurl`, `readurl|command`, `readurl|completion`,\n  `readurl|null`; the part after the `|` has the same meaning as in the normal `as''` ice.\n\nSo, for example:\n\n```zsh\nzinit for \\\n    as'readurl|command' \\\n    dlink'/junegunn/fzf-bin/releases/download/%VERSION%/fzf-%VERSION%-linux_amd64.tgz'\n    extract \\\n    id-as'fzf'\n  https://github.com/junegunn/fzf-bin/releases/\n```\n\nThe snippet is just an example. The same effect is obtained by loading as `junegunn/fzf-bin` plugin with `from'gh-r'`\nice.\n\nAs demonstrated, the `dlink''` can be a relative or an absolute path and also a full URL (i.e.: beginning with the\n`http://…` prefix).\n\n## Intermediate Download Page\u003ca name=\"intermediate-download-page\"\u003e\u003c/a\u003e\n\nSometimes, like in the case of the [terraform](http://releases.hashicorp.com/terraform) command, the download link isn't\non the download page but on a page listed on it. In such cases utilize the `dlink0''` ice and provide the pattern for\nthe additional, intermediate download page. For For example, in the case of `terraform`, the Zinit command is:\n\n```zsh\nzinit for \\\n    as'readurl|command' \\\n    dlink0'/terraform/%VERSION%/' \\\n    dlink'/terraform/%VERSION%/terraform_%VERSION%_linux_386.zip' \\\n    extract \\\n    id-as'terraform' \\\n  http://releases.hashicorp.com/terraform/\n```\n\n## Skipping `dlink''` Ice\u003ca name=\"skipping-dlink-ice\"\u003e\u003c/a\u003e\n\nSometimes the URL of the download page differs from the URL of the archive in just a few `/`-sections. In such a case,\nit is possible to skip the `dlink''` ice by appending a `++`-separated fragment of the archive URL, like so:\n\n```zsh\nzinit for \\\n    as'readurl|command' \\\n    extract \\\n  http://domain.com/download-page++/archive.zip\n```\n\nIf the archive URL has some different `/`-sections, then it's possible to strip the conflicting ones from the download\nURL by using `+++`, `++++`, etc. – the number of the `/`-section that'll be stripped equals the number of the `+` minus\n2\\. So, for example:\n\n```zsh\nzinit for \\\n    as'readurl|command' \\\n    extract \\\n  http://domain.com/download-page/removed-section+++/archive.zip\n```\n\n## Sorting matched URLs/versions\u003ca name=\"sorting-matched-urlsversions\"\u003e\u003c/a\u003e\n\nSometimes the download page doesn't list the package versions from newest to the oldest, but in some other order. In\nsuch case, it's possible to sort the URLs / package versions by prepending the chosen `dlink` ice (`dlink0''` or\n`dlink''`) with the exclamation mark (`dlink'!…'`, etc.). See the next section for an example:\n\n## Filtering The Matched URLs\u003ca name=\"filtering-the-matched-urls\"\u003e\u003c/a\u003e\n\nSometimes some unwanted URLs match the `dlink''`/`dlink0''` regex/pattern. In such case it's possible to filter them out\nby appending a filtering regex to the `dlink''` ice as: `dlink='the-main-regex~%the-unwanted-URLs-regex%'` (or the same\nfor `dlink0''`). An example package that can benefit from this is the [Open Shift](https://www.openshift.com/) client,\nwhich doesn't sort the URLs from latest to the oldest – hence the exclamation mark (`!`) prepend – and it has special\nURLs like `stable-4.4` or `candidate-4.5` together with the regular version URLs (like `4.5.0-rc.1`):\n\n```zsh\nzinit for \\\n    as'readurl|command' \\\n    dlink'openshift-client-windows-%VERSION%.zip' \\\n    dlink0'!%VERSION%~%(stable|latest|fast|candidate).*%' \\\n    id-as'ocp' \\\n  https://mirror.openshift.com/pub/openshift-v4/clients/ocp/\n```\n\nThe above snippet of Zsh code / Zinit invocation will sort the URLs (`dlink0'!…'`) and then filter out the special ones\nfrom the results (via `…~%(stable|latest|fast|candidate).*%`), this way selecting the latest version of the Open Shift\nclient.\n\n## Examples\u003ca name=\"examples\"\u003e\u003c/a\u003e\n\n[**Pulumi**](https://www.pulumi.com/), a tool to create, deploy, and manage modern cloud software.\n\n```zsh\nzi for \\\n    as'readurl|null' \\\n    dlink'https://get.pulumi.com/releases/sdk/pulumi-%VERSION%-linux-x64.tar.gz' \\\n    extract'!' \\\n    id-as'pulumi' \\\n    sbin'pulumi*' \\\n  https://www.pulumi.com/docs/get-started/install/versions/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzdharma-continuum%2Fzinit-annex-readurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzdharma-continuum%2Fzinit-annex-readurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzdharma-continuum%2Fzinit-annex-readurl/lists"}