🌀 Read URL
An annex allows automatically downloading the newest version of a file to which the URL is hosted on a webpage. It works as follows:
Invoke snippet
(or simply pass the https://…
address using the for
syntax) on the web page that hosts the URL to the file to download, provide dlink'…'
ice with the expected file-download URL replacing the version with the %VERSION%
keyword, also provide as'…'
ice with one of the following values:
readurl
,readurl|command
,readurl|completion
,readurl|null
.
The part after the |
has the same meaning as in the normal as'…'
ice.
Examples
zi id-as=fzf as='readurl|command' for \
dlink='/junegunn/fzf/releases/download/%VERSION%/fzf-%VERSION%-linux_amd64.tar.gz' \
https://github.com/junegunn/fzf/releases/
The snippet is just an example. The same effect is obtained by loading as the junegunn/fzf
plugin with from'gh-r'
ice.
As it can be seen, the dlink'…'
can be a relative or an absolute path and also a full URL (i.e.: beginning with the https://…
prefix).
Intermediate download page
Sometimes, like it is in the case of the terraform command, the final download link isn't on the download page, but on a page, that's listed on it. In such a case use the dlink0'…'
ice to provide the pattern for the additional, intermediate download page, e.g.:
zi id-as=terraform as='readurl|command' extract for \
dlink0='/terraform/%VERSION%/' \
dlink='/terraform/%VERSION%/terraform_%VERSION%_linux_386.zip' \
https://releases.hashicorp.com/terraform/