#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"'

BASE_SHELL=${BASE_SHELL:-${SHELL##*/}}

if is_cmd atuin; then
    if [[ "${BASE_SHELL}" == "bash" ]] && ! [[ -n "$SZ_ENV_BASH_LOAD_PREEXEC$BLE_VERSION" ]]; then
        printf '%s\n' \
            'atuin was found, but bash-preexec or ble.sh are not loaded,' \
            'to load atuin, first run update-ble.sh or update-bash-preexec ' \
            'then relaod (_r) the shell.'
    fi

    . <( atuin init "${BASE_SHELL}" )
    . <( atuin gen-completions --shell ${BASE_SHELL} )

    [[ -n "${DBG}" ]] && echo "atuin loaded."
fi