-
-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix no-exec commands not making it into the history #1319
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Totally happy to merge this - however I would like to wait until after v17, which I'm releasing this week (now that I am properly home). It's a small change but has a large potential for unknown issues, so I'd like to run it for a while before release. |
For the time being one can add this snippet to their if echo "${preexec_functions}" | grep -qs atuin; then
add-zsh-hook -d preexec _atuin_preexec
add-zsh-hook zshaddhistory _atuin_preexec
else
echo "remove atuin zshaddhistory hook workaround"
fi |
So after running it for two weeks now, the only issue I encounter is that occasionally empty history items make it into the history. |
I've added the check
|
@@ -12,6 +12,9 @@ autoload -U add-zsh-hook | |||
export ATUIN_SESSION=$(atuin uuid) | |||
|
|||
_atuin_preexec() { | |||
# skip history for empty calls | |||
# remove space, \t, \n, and literal '\' | |||
[[ -n "${${1//[[:space:]]/}//\\/}" ]] || return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate why this is here, but would it be possible to implement it rust-side instead? we could then add some tests as well and ensure it doesn't happen for any shell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be the right place to introduce such a check?
atuin/atuin/src/command/client/history.rs
Line 293 in 1a432b6
let command = command.join(" "); |
32058fe
to
c2c1c10
Compare
c2c1c10
to
dab5207
Compare
Fixes #467
Uses the same as zsh-histdb.
This will fix not adding to the history:
#
so#echo asdf
will be stored in the history, even if you are using zshsetopt interactivecomments
https://github.com/larkery/zsh-histdb/blob/30797f0c50c31c8d8de32386970c5d480e5ab35d/sqlite-history.zsh#L175C14-L175C27
Link to official zsh docs on this
https://zsh.sourceforge.io/Doc/Release/Functions.html#:~:text=is%20being%20executed.-,zshaddhistory,-Executed%20when%20a