# chezmoi:template:left-delimiter=#{{
#{{- /* vim: set filetype=sh: */ -}}

export LANGUAGE=en_US:en
export LC_MESSAGES=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export LC_COLLATE=en_US.UTF-8

export XDG_BIN_HOME="${XDG_BIN_HOME:=$HOME/.local/bin}"
export XDG_CACHE_HOME="${XDG_CACHE_HOME:=$HOME/.cache}"
export XDG_CONFIG_DIRS="${XDG_CONFIG_DIRS:=/etc/xdg}"
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:=$HOME/.config}"
export XDG_DATA_DIRS="${XDG_DATA_DIRS:=/usr/local/share:/usr/share}"
export XDG_DATA_HOME="${XDG_DATA_HOME:=$HOME/.local/share}"
export XDG_INCLUDE_HOME="${XDG_INCLUDE_HOME:=$HOME/.local/include}"
export XDG_STATE_HOME="${XDG_STATE_HOME:=$HOME/.local/state}"

_env_file () {
    if [ ! -f "${1}" ]; then
        return
    fi
    eval "$(
        grep -v '^\s*\#' "${1}" |
        grep -v '^\s*$' |
        sed 's/^\s*export//g' |
        sed 's/^/export /g'
    )"
}

#{{ $home := .chezmoi.homeDir -}}
_env_file "${XDG_CONFIG_HOME}/user-dirs.dirs"
#{{- range $file := (glob (joinPath $home ".config" "profile" "env.d" "*.env")) }}
_env_file "#{{ replace $home "${HOME}" $file }}"
#{{- end }}
unset _env_file

#{{ range $file := (glob (joinPath $home ".config" "profile" "profile.d" "*.sh")) }}
. "#{{ replace $home "${HOME}" $file }}"
#{{- end }}