encryption = "age"
[age]
    identity = "{{ .chezmoi.homeDir }}/.age/key.txt"
    recipient = "age1w8ms9vszzf20ln5tmztwmmrseecjywh7k36rt0lcep62nqk76f7sa3l4pt"

[data]
    hostname = {{ .chezmoi.hostname | quote }}
    {{- if eq .chezmoi.os "linux" }}
    {{-   if (.chezmoi.kernel.osrelease | lower | contains "arch") }}
    distro = "arch"
    {{-   end }}
    {{- end }}

[diff]
{{- if lookPath "delta" }}
    command = "delta"
    pager = "delta"
{{- else }}
    command = "diff"
    pager = "less"
{{- end }}

[edit]
{{- if lookPath "nvim" }}
    command = "nvim"
{{- else if lookPath "vim" }}
    command = "vim"
{{- else }}
    command = "nano"
{{- end }}

[git]
    autoCommit = true
    autoPush = true
    commitMessageTemplate = """\
    {{ "{{-" }} $files := index . "files" {{ "}}" }}
    {{ "{{-" }} if not (and $files (gt (len $files) 0)) {{ "}}" }}
    chore: Files removed or no specific files modified.
    {{ "{{-" }} else {{ "}}" }}
    {{ "{{-" }} $path := list {{ "}}" }}
    {{ "{{-" }} range $files {{ "}}" }}
    {{ "{{-" }} $path = append $path .path {{ "}}" }}
    {{ "{{-" }} end {{ "-}}" }}
    {{ "{{-" }} $firstFile := index $path 0 {{ "-}}" }}
    {{ "{{-" }} $dir := dir $firstFile {{ "-}}" }}

    {{ "{{-" }} if contains "encrypted_" $firstFile {{ "-}}" }}
    security(secret): {{ "{{" }} if eq (len $files) 1 {{ "}}" }}update {{ "{{" }} base $firstFile {{ "}}" }}{{ "{{" }} else {{ "}}" }}update multiple encrypted files{{ "{{" }} end {{ "}}" }}
    {{ "{{-" }} else if contains "scripts/" $firstFile {{ "-}}" }}
    script({{ "{{" }} $dir {{ "}}" }}): {{ "{{" }} if eq (len $files) 1 {{ "}}" }}update {{ "{{" }} base $firstFile {{ "}}" }}{{ "{{" }} else {{ "}}" }}update multiple script files{{ "{{" }} end {{ "}}" }}
    {{ "{{-" }} else if contains "exact_" $firstFile {{ "-}}" }}
    chore(external): {{ "{{" }} if eq (len $files) 1 {{ "}}" }}update {{ "{{" }} base $firstFile {{ "}}" }}{{ "{{" }} else {{ "}}" }}update external dependencies{{ "{{" }} end {{ "}}" }}
    {{ "{{-" }} else {{ "-}}" }}
    chore({{ "{{" }} $dir {{ "}}" }}): {{ "{{" }} if eq (len $files) 1 {{ "}}" }}update {{ "{{" }} base $firstFile {{ "}}" }}{{ "{{" }} else {{ "}}" }}update multiple files{{ "{{" }} end {{ "}}" }}
    {{ "{{-" }} end {{ "}}" }}

    {{ "{{-" }} if gt (len $files) 1 {{ "}}" }}

    Modified files:
    {{ "{{-" }} range $files {{ "}}" }}
    {{ "- {{" }} .path {{ "}}" }}
    {{ "{{-" }} end {{ "}}" }}
    {{ "{{-" }} end {{ "}}" }}
    {{ "{{-" }} end {{ "}}" }}
    """

[git.commit]
    gpgsign = true
    signoff = true

[git.push]
    followTags = true

{{- if stat (joinPath .chezmoi.sourceDir "hooks/pre-commit") }}
[git.hooks]
    pre-commit = "{{ .chezmoi.sourceDir }}/hooks/pre-commit"
    commit-msg = "{{ .chezmoi.sourceDir }}/hooks/commit-msg"
    post-commit = "{{ .chezmoi.sourceDir }}/hooks/post-commit"
{{- end }}

[merge]
{{- if lookPath "nvim" }}
    command = "nvim"
    args = ["-d", "{{ "{{ .Destination }}" }}", "{{ "{{ .Source }}" }}", "{{ "{{ .Target }}" }}"]
{{- else if lookPath "vimdiff" }}
    command = "vimdiff"
    args = ["{{ "{{ .Destination }}" }}", "{{ "{{ .Source }}" }}", "{{ "{{ .Target }}" }}"]
{{- end }}
