summaryrefslogtreecommitdiffstats
path: root/hook.zsh
diff options
context:
space:
mode:
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