Skip to content

Instantly share code, notes, and snippets.

@ThePsyjo
Created July 21, 2023 10:46
Show Gist options
  • Save ThePsyjo/c8ee15762cbd6de991cf10c29a05f9e4 to your computer and use it in GitHub Desktop.
Save ThePsyjo/c8ee15762cbd6de991cf10c29a05f9e4 to your computer and use it in GitHub Desktop.
Atuin delete session history on exit
# run `nh` any time in the session to delete it's history on session exit.
alias nh="export ATUIN_DELETE_HISTORY=1"
__delete_history_on_exit() {
if [[ $ATUIN_DELETE_HISTORY ]]
then
# echo $ATUIN_SESSION >> /tmp/debug
# stick to tomlq to get the db from config or hardcode db path here
db=$(tomlq -c .db_path < ~/.config/atuin/config.toml)
[[ "${db}" == "null" || -z "${db}" ]] && db="~/.local/share/atuin/history.db"
# echo "${db}" >> /tmp/debug
# sqlite3 "${db}" <<< "SELECT COUNT(*) FROM history WHERE session = '${ATUIN_SESSION}'" >> /tmp/debug
sqlite3 "${db}" <<< "DELETE FROM history WHERE session = '${ATUIN_SESSION}'"
fi
}
trap __delete_history_on_exit EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment