# source by .chezmoi.toml.tmpl, it is recommended to edit with
#   cz edit-config-template && cz init

{{- $githubToken := get . "githubToken" | default "" -}}
{{- $githubToken = or (
        env "CZ_GITHUB_ACCESS_TOKEN"
    ) ( env "CHEZMOI_GITHUB_ACCESS_TOKEN"
    ) ( env "GITHUB_ACCESS_TOKEN"
    ) ( env "GITHUB_TOKEN"
    ) ( promptStringOnce . "githubToken" "Public GITHUB token (mostly for rate limits - !insecure!)" $githubToken
    ) -}}
{{- $sysname := promptStringOnce . "sysname" "System name" (or (
        get . "sysname"
    ) ( env "CZ_SYSNAME"
    ) ( .chezmoi.hostname
    )) -}}
{{- $sysgroup := promptStringOnce . "sysgroup" "System group" (or (
        env "CZ_SYSGROUP"
    ) ( .chezmoi.group
    )) -}}
{{- $sysuser := promptStringOnce . "sysuser" "System user" (or (
        env "CZ_SYSUSER"
    ) ( .chezmoi.username
    )) -}}
{{- $gitEmail := promptStringOnce . "gitEmail" "email address (for git commits)" (or (
        env "CZ_GIT_EMAIL"
    ) ( output "sh" "-c" "git config user.email || true"
    ) ( list .chezmoi.username "@" .chezmoi.fqdnHostname | join ""
    )) -}}
{{- $gitName := promptStringOnce . "gitName" "Full name (for git commits)" (or (
        env "CZ_GIT_NAME"
    ) ( output "sh" "-c" "git config user.name || true"
    ) ( list .chezmoi.username " (@" $sysname ")" | join ""
    )) -}}

{{- $zellijLeaderModifier := list (dig "style" "zellij" "leader-modifier" "Alt" .) "dummy" | join " " | splitList " " -}}
{{- $zellijLeaderModifier  = slice $zellijLeaderModifier 0 (sub (len $zellijLeaderModifier) 1) -}}
{{- $zellijLeaderModifierChoices := list "Alt" "Ctrl" -}}
{{- $zellijLeaderModifierSelected := promptMultichoice "Choose zellij Leader Modifyer" $zellijLeaderModifierChoices $zellijLeaderModifier -}}
{{- $zellijLeaderModifier = $zellijLeaderModifierSelected | join " " -}}

{{- $zellijLeaderKey := promptString "Choose zellij Leader Key" (dig "style" "zellij" "leader-key" "a" .) -}}

{{- $zellijFrames := dig "style" "zellij" "frames" "y" . -}}
{{- $zellijFrames  = promptChoice "Should zellij show pane frames? (y/n)" (list "y" "n" ) $zellijFrames -}}

{{- $zellijTheme := dig "style" "zellij" "theme" "default" . -}}
{{- $zellijThemeChoices := list "default"
        "ansi" "ao" "atelier-sulphurpool" "ayu_mirage" "ayu_dark"
        "catppuccin-frappe" "catppuccin-macchiato" "cyber-noir" "blade-runner"
        "retro-wave" "dracula" "everforest-dark" "gruvbox-dark" "iceberg-dark"
        "kanagawa" "lucario" "menace" "molokai-dark" "night-owl" "nightfox"
        "nord" "one-half-dark" "onedark" "solarized-dark" "tokyo-night-dark"
        "tokyo-night-storm" "tokyo-night" "vesper"
-}}
{{- $zellijThemeSelected := promptMultichoice (list "Choose zellij theme *(only first selection is chose - default is '" $zellijTheme "')" | join "") $zellijThemeChoices -}}
{{- $zellijTheme = first $zellijThemeSelected | default $zellijTheme -}}

{{- $promptStyle := dig "style" "prompt" "cool" . -}}
{{- $promptStyleChoices := list "cool" "hot" "lux" -}}
{{- $promptStyleSelected := promptMultichoice (list "Choose prompt style *(only first selection is chose - default is '" $promptStyle "')" | join "") $promptStyleChoices -}}
{{- $promptStyle = first $promptStyleSelected | default $promptStyle -}}
{{/*{{- $promptStyle = promptChoice "Prompt style" $promptStyleChoices $promptStyle -}}*/}}

{{- $scriptTempDir   := or ( get . "sz.os.scriptTempDir"   ) ( env "CZ_SCRIPT_TEMPDIR"      ) -}}
{{- $chassisType     := or ( get . "sz.os.chassisType"     ) ( env "CZ_CHASSIS"             ) -}}
{{- $sysType         := or ( get . "sz.os.sysType"         ) ( env "CZ_SYS"                 ) -}}
{{- $sysVendor       := or ( get . "sz.os.sysVendor"       ) ( env "CZ_VENDOR"              ) -}}

{{- $arch_alt := "x86_64" -}}
{{- $arch_alt_dash := "x86-64" -}}
{{- $clib_flavor := "" -}}
{{- if eq .chezmoi.os "darwin" -}}
{{-   $arch_alt = "aarch64" -}}
{{-   $arch_alt_dash = $arch_alt -}}
{{- else if eq .chezmoi.os "linux" -}}
{{-   $clib_flavor = "-musl" -}}
{{- else if eq .chezmoi.os "windows" -}}
{{-   $clib_flavor = "-msvc" -}}
{{- end -}}

{{- $scriptTempDir := "~/.cache/chezmoi/tmp" }}
scriptTempDir={{ $scriptTempDir | quote }}

[data.sz.os]
{{- if eq .chezmoi.os "linux" }}
   short={{- .chezmoi.os | quote }}
{{- else if eq .chezmoi.os "darwin" }}
   short="mac"
{{- else }}
   short={{- substr 0 3 (.chezmoi.os) | quote }}
{{- end }}
   rust_rel_target={{- printf "%s-%s%s" $sysVendor .chezmoi.os $clib_flavor | quote }}
{{- if ($arch_alt) }}
   arch_alt={{- $arch_alt | quote }}
{{- end }}
{{- if ($arch_alt_dash) }}
   arch_alt_dash={{- $arch_alt_dash | quote }}
{{- end }}
{{- if ($chassisType) }}
   chassisType={{- $chassisType | quote }}
{{- end }}
{{- if ($sysType) }}
   sysType={{- $sysType | quote }}
{{- end }}

[data]
{{- if ($githubToken) }}
   githubToken={{- $githubToken | quote }}
{{- end }}
{{- if ($sysname) }}
   sysname = {{ $sysname | quote }}
{{- end }}
{{- if ($sysgroup) }}
   sysgroup = {{ $sysgroup | quote }}
{{- end }}
{{- if ($sysuser) }}
   sysuser = {{ $sysuser | quote }}
{{- end }}

{{- if ($gitEmail) }}
   gitEmail = {{ $gitEmail | quote }}
{{- end }}
{{- if ($gitName) }}
   gitName = {{ $gitName | quote }}
{{- end }}
{{- if not ($githubToken) }}
   githubToken={{- $githubToken | quote }}
{{- end }}

[scriptEnv]
   CZ_SCRIPT_TEMPDIR={{- $scriptTempDir | quote }}
   CZ_CHASSIS={{- $chassisType | quote }}
   CZ_SYS={{- $sysType | quote }}
   CZ_OS={{- .chezmoi.os | quote }}
   CZ_GITHUB_ACCESS_TOKEN={{- $githubToken | quote }}
   CZ_VENDOR={{- $sysVendor | quote }}
   GITHUB_ACCESS_TOKEN={{- $githubToken | quote }}
   GITHUB_TOKEN={{- $githubToken | quote }}

[data.style]
{{- if ($promptStyle) }}
   prompt={{- $promptStyle | quote }}
{{- end }}

[data.style.zellij]
{{- if ($zellijFrames) }}
   frames={{- $zellijFrames | quote }}
{{- end }}
{{- if ($zellijTheme) }}
   theme={{- $zellijTheme | quote }}
{{- end }}
{{- if ($zellijLeaderModifier) }}
   leader-modifier={{- $zellijLeaderModifier | quote }}
{{- end }}
{{- if ($zellijLeaderKey) }}
   leader-key={{- $zellijLeaderKey | quote }}
{{- end }}

{{- if lookPath "delta" }}
[diff]
#   command = "nvim"
#   args = ["-d",  "{{ "{{ .Destination }}" }}", "{{ "{{ .Target }}" }}"]

   command = "delta"
   args = ["--paging=never", "{{ "{{ .Destination }}" }}", "{{ "{{ .Target }}" }}"]
   pager = "moar"
{{- end -}}

# vim: set ft=toml expandtab tabstop=2 shiftwidth=2: