From 7e60ace610ea3d137fac8fd6cfb26a1f5411a609 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Sat, 13 Feb 2021 17:02:52 +0000 Subject: Record command exit code and duration --- hook.zsh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'hook.zsh') diff --git a/hook.zsh b/hook.zsh index ae1ca7b8..8fd9beb6 100644 --- a/hook.zsh +++ b/hook.zsh @@ -1,7 +1,17 @@ # Source this in your ~/.zshrc _atuin_preexec(){ - atuin history add $1 + id=$(atuin history start $1) + export ATUIN_HISTORY_ID="$id" +} + +_atuin_precmd(){ + local EXIT="$?" + + [[ -z "${ATUIN_HISTORY_ID}" ]] && return + + atuin history end $ATUIN_HISTORY_ID --exit $EXIT } add-zsh-hook preexec _atuin_preexec +add-zsh-hook precmd _atuin_precmd -- cgit v1.3.1