# chezmoi:template:left-delimiter=#{{
#{{- /* vim: set filetype=bash: */ -}}
#!/usr/bin/env bash

source "${HOME}/.profile"

# if not running interactively, don't do anything more
[ -z "$PS1" ] && return

#{{- if not (lookPath "starship") }}
if [[ -f "${XDG_CONFIG_HOME}/bash/prompt.sh" ]]; then
    # shellcheck disable=SC1090
    source "${XDG_CONFIG_HOME}/bash/prompt.sh"
fi
#{{- end }}

#{{- $home := .chezmoi.homeDir }}
#{{ range $file := (glob (joinPath $home ".config" "bash" "bashrc.d" "*.sh")) }}
source "#{{ replace $home "${HOME}" $file }}"
#{{- end }}

_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'
    )"
}
#{{ range $file := (glob (joinPath $home ".config" "bash" "env.d" "*.env")) }}
_env_file "#{{ replace $home "${HOME}" $file }}"
#{{- end }}

unset _env_file