aboutsummaryrefslogtreecommitdiffstats
path: root/hook.zsh
diff options
context:
space:
mode:
authorEllie Huxtable <e@elm.sh>2021-02-13 17:02:52 +0000
committerEllie Huxtable <e@elm.sh>2021-02-13 17:02:52 +0000
commit7e60ace610ea3d137fac8fd6cfb26a1f5411a609 (patch)
tree493142aa562fa379f82e4f6b2e2a79fa7f9b085b /hook.zsh
parentBegin import (diff)
downloadatuin-7e60ace610ea3d137fac8fd6cfb26a1f5411a609.zip
Record command exit code and duration
Diffstat (limited to 'hook.zsh')
-rw-r--r--hook.zsh12
1 files changed, 11 insertions, 1 deletions
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