[!windows] chmod 755 bin/secret
[windows] unix2dos bin/secret.cmd

chezmoi secret generic examplepassword
stdout examplepassword

chezmoi apply
cmp $HOME/.netrc golden/.netrc

[short] stop

-- bin/secret --
#!/bin/sh

echo "$*"
-- bin/secret.cmd --
@echo off
setlocal
set out=%*
set out=%out:\=%
echo %out%
endlocal
-- golden/.netrc --
machine example.com
login examplelogin
password examplepassword

machine example2.com
login examplelogin2
password examplepassword2
-- home/user/.config/chezmoi/chezmoi.toml --
[genericSecret]
    command = "secret"
-- home/user/.local/share/chezmoi/private_dot_netrc.tmpl --
machine example.com
login examplelogin
password {{ secret "examplepassword" }}

machine example2.com
login {{ (secretJSON "{\"username\":\"examplelogin2\",\"password\":\"examplepassword2\"}").username }}
password {{ (secretJSON "{\"username\":\"examplelogin2\",\"password\":\"examplepassword2\"}").password }}
