2024-05-04 21:05:33 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# @file Atuin Initialization
|
|
|
|
# @brief Registers with atuin, logs in, imports command history, and synchronizes
|
|
|
|
|
2024-05-27 20:45:14 -07:00
|
|
|
set -Eeuo pipefail
|
2024-05-27 20:50:11 -07:00
|
|
|
trap "gum log -sl error 'Script encountered an error!'" ERR
|
2024-05-27 04:15:03 -07:00
|
|
|
|
2024-05-04 21:05:33 -07:00
|
|
|
if command -v atuin > /dev/null; then
|
2024-05-27 20:45:14 -07:00
|
|
|
if get-secret --exists ATUIN_USERNAME ATUIN_EMAIL ATUIN_PASSWORD ATUIN_KEY; then
|
2024-05-27 20:50:11 -07:00
|
|
|
gum log -sl info 'Registering Atuin account'
|
2024-05-27 23:55:42 -07:00
|
|
|
atuin register -u "$(get-secret ATUIN_USERNAME)" -e "$(get-secret ATUIN_EMAIL)" -p "$(get-secret ATUIN_PASSWORD)" || true
|
2024-05-27 20:50:11 -07:00
|
|
|
gum log -sl info 'Logging into Atuin account'
|
2024-05-27 20:45:14 -07:00
|
|
|
atuin login -u "$(get-secret ATUIN_USERNAME)" -p "$(get-secret ATUIN_PASSWORD)" -k "$(get-secret ATUIN_KEY)"
|
2024-05-27 20:50:11 -07:00
|
|
|
gum log -sl info 'Running atuin import auto'
|
2024-05-27 20:45:14 -07:00
|
|
|
atuin import auto
|
2024-05-27 20:50:11 -07:00
|
|
|
gum log -sl info 'Running atuin sync'
|
2024-05-27 20:45:14 -07:00
|
|
|
atuin sync
|
|
|
|
fi
|
2024-05-04 21:05:33 -07:00
|
|
|
else
|
2024-05-27 20:50:11 -07:00
|
|
|
gum log -sl info 'atuin is not available in the PATH'
|
2024-05-04 21:05:33 -07:00
|
|
|
fi
|