fix(bash): avoid unexpected atuin history start for keybindings#1509
Merged
ellie merged 1 commit intoatuinsh:mainfrom Jan 6, 2024
Merged
fix(bash): avoid unexpected atuin history start for keybindings#1509ellie merged 1 commit intoatuinsh:mainfrom
atuin history start for keybindings#1509ellie merged 1 commit intoatuinsh:mainfrom
Conversation
This fixes the second issue of "0s or wrong command duration" reported at atuinsh#1003. The problem is that, with bash-preexec, the preexec hook may be called even for the commands executed by the keybindings. * In particular, the preexec is called before the command `__atuin_history` is executed on pressing [C-r] and [up]. In this case, $1 passed to `__atuin_preexec` contains the last entry in the command history, so `atuin history start` is called for the last command. As a result, pressing [C-r] and [up] clears the duration of the last command. This causes the reported 0s duration. * Furthermore, the precmd hook corresponding to the keybinding command will not be called, so the duration is only filled when the next user command starts. This replaces the duration of the last command with the time interval between the last press of [C-r] or [up] and the start time of the next command. This causes the reported wrong duration. There is no general and robust way to distinguish the preexec invocation for keybindings from that for the user commands, but in this patch we exclude the preexec invocation for Atuin's keybindings [C-r] and [up] at least.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Contributor
Author
|
Thanks! |
Member
|
Hey! It looks like this one caused a regression. I'm struggling to get bash to record much input at all with preexec and this patch. Reverting it solved all issues for me |
akinomyoga
added a commit
to akinomyoga/atuin
that referenced
this pull request
Feb 17, 2024
In GitHub atuinsh#1509, we blocked the unintended preexec caused by the keybinding of Atuin. However, with that fix, the preexec event for the intended user command is still missing. In this patch, we try to manually run the preexec hook when we detected the unintended preexec (which means the missing intended preexec). References: atuinsh#1509 atuinsh#1727 atuinsh#1728
akinomyoga
added a commit
to akinomyoga/atuin
that referenced
this pull request
Feb 17, 2024
In GitHub atuinsh#1509, we blocked the unintended preexec caused by the keybinding of Atuin. However, with that fix, the preexec event for the intended user command is still missing. In this patch, we try to manually run the preexec hook when we detected the unintended preexec (which means the missing intended preexec). References: atuinsh#1509 atuinsh#1727 atuinsh#1728
akinomyoga
added a commit
to akinomyoga/atuin
that referenced
this pull request
Feb 17, 2024
In GitHub atuinsh#1509, we blocked the unintended preexec caused by the keybinding of Atuin. However, with that fix, the preexec event for the intended user command is still missing. In this patch, we try to manually run the preexec hook when we detected the unintended preexec (which means the missing intended preexec). References: atuinsh#1509 https://forum.atuin.sh/t/atuin-bash-and-ble-sh/175 atuinsh#1003 (comment) atuinsh#1727 atuinsh#1728
akinomyoga
added a commit
to akinomyoga/atuin
that referenced
this pull request
Feb 17, 2024
In GitHub atuinsh#1509, we blocked the unintended preexec caused by the keybinding of Atuin. However, with that fix, the preexec event for the intended user command is still missing. In this patch, we try to manually run the preexec hook when we detected the unintended preexec (which means the missing intended preexec). References: atuinsh#1509 https://forum.atuin.sh/t/atuin-bash-and-ble-sh/175 atuinsh#1003 (comment) atuinsh#1727 atuinsh#1728
2 tasks
akinomyoga
added a commit
to akinomyoga/atuin
that referenced
this pull request
Feb 17, 2024
In GitHub atuinsh#1509, we blocked the unintended preexec event caused by the keybinding of Atuin. However, with that fix, the preexec event for the intended user command is still missing. In this patch, we try to manually run the preexec hook when we detected the unintended preexec (which means the missing intended preexec). References: atuinsh#1509 https://forum.atuin.sh/t/atuin-bash-and-ble-sh/175 atuinsh#1003 (comment) atuinsh#1727 atuinsh#1728
ellie
pushed a commit
that referenced
this pull request
Feb 17, 2024
In GitHub #1509, we blocked the unintended preexec event caused by the keybinding of Atuin. However, with that fix, the preexec event for the intended user command is still missing. In this patch, we try to manually run the preexec hook when we detected the unintended preexec (which means the missing intended preexec). References: #1509 https://forum.atuin.sh/t/atuin-bash-and-ble-sh/175 #1003 (comment) #1727 #1728
ellie
pushed a commit
that referenced
this pull request
Feb 26, 2024
In GitHub #1509, we blocked the unintended preexec event caused by the keybinding of Atuin. However, with that fix, the preexec event for the intended user command is still missing. In this patch, we try to manually run the preexec hook when we detected the unintended preexec (which means the missing intended preexec). References: #1509 https://forum.atuin.sh/t/atuin-bash-and-ble-sh/175 #1003 (comment) #1727 #1728
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the second issue reported at #1003 by @gvlassis, i.e., the issue of "0s or wrong command duration".
The problem is that, with bash-preexec, the preexec hook may be called even for the commands executed by the keybindings.
In particular, the preexec is called before the command
__atuin_historyis executed on pressing C-r and up. In this case,$1passed to__atuin_preexeccontains the last entry in the command history, soatuin history startis called for the last command. As a result, pressing C-r and up clears the duration of the last command. This causes the reported 0s duration.Furthermore, the precmd hook corresponding to the keybinding command will not be called, so the duration is only filled when the next user command starts. This replaces the duration of the last command with the time interval between the last press of C-r or up and the start time of the next command. This causes the reported wrong duration.
There is no general and robust way to distinguish the preexec invocation for keybindings from that for the user commands, but in this patch, we exclude the preexec invocation for Atuin's keybindings to C-r and up at least.