Skip to content

Commit

Permalink
docs: Document extracting a single file from an archive
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Feb 24, 2022
1 parent 766356d commit 3f36946
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions assets/chezmoi.io/docs/user-guide/include-files-from-elsewhere.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,28 @@ You can customize the arguments to `git clone` and `git pull` by setting the
chezmoi's support for `git-repo` externals currently requires `git` to be
in your `$PATH`.

## Extract a single file from an archive

You can extract a single file from an archive using the
`<entry>.filter.command` and `<entry>.filter.args` variables in
`.chezmoiexternal.<format>`, for example:

```toml title="~/.local/share/chezmoi/.chezmoiexternal.toml"
{{ ageVersion := "1.0.0" -}}
[".local/bin/age"]
type = "file"
url = "https://github.com/FiloSottile/age/releases/download/v{{ $ageVersion }}/age-v{{ $ageVersion }}-{{ .chezmoi.os }}-{{ .chezmoi.arch }}.tar.gz"
executable = true
refreshPeriod = "168h"
[".local/bin/age".filter]
command = "tar"
args = ["--extract", "--file", "/dev/stdin", "--gzip", "--to-stdout", "age/age"]
```

This will extract the single archive member `age/age` from the given URL (which
is computed for the current OS and architecture) to the target
`./local/bin/age` and set its executable bit.

## Import archives

It is occasionally useful to import entire archives of configuration into your
Expand Down

0 comments on commit 3f36946

Please sign in to comment.