fix: Pressing 'enter' after a suggested command inserts instead of runs in bash#3592
Draft
BinaryMuse wants to merge 1 commit into
Draft
fix: Pressing 'enter' after a suggested command inserts instead of runs in bash#3592BinaryMuse wants to merge 1 commit into
BinaryMuse wants to merge 1 commit into
Conversation
The bash integration's __atuin_ai_execute__ branch set READLINE_LINE and then bound two key sequences that nothing ever invoked, so "execute" behaved identically to "insert" — accepting an AI suggestion with enter just placed it in the buffer. Readline provides no way to call accept-line from a shell function, so this uses the same string-macro trick as atuin.bash's enter_accept support: "?" is bound to a two-part macro where the first keyseq runs the widget via bind -x and the trailing keyseq is dynamically rebound to accept-line (execute) or a no-op (everything else). Under ble.sh the widget calls ble/widget/accept-line directly. Bash <= 4.2 can't bind -x multi-byte key sequences, so it keeps the direct binding and execute still degrades to insert there. Also removes the dead __atuin_ai_accept_line / _atuin_ai_question_mark_wrapper scaffolding. Verified in interactive bash 5.3 via expect with a stubbed atuin: execute runs without pressing enter, insert leaves the command in the buffer (including immediately after an execute, exercising the trailer reset), mid-line "?" inserts literally, and vi editing mode works.
Contributor
Greptile SummaryThis PR fixes bash AI suggestions so execute suggestions can submit the command.
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "Fix AI execute mode in bash: enter now r..." | Re-trigger Greptile |
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.
The bash integration's
__atuin_ai_execute__branch setREADLINE_LINEand then bound two key sequences that nothing ever invoked, so "execute" behaved identically to "insert": accepting an AI suggestion with enter just placed it in the buffer.Readline provides no way to call accept-line from a shell function, so this uses the same string-macro trick as
atuin.bash's enter_accept support: "?" is bound to a two-part macro where the first keyseq runs the widget viabind -xand the trailing keyseq is dynamically rebound toaccept-line(execute) or a no-op (everything else). Under ble.sh the widget callsble/widget/accept-linedirectly. Bash <= 4.2 can'tbind -xmulti-byte key sequences, so it keeps the direct binding and execute still degrades to insert there.Also removes the dead
__atuin_ai_accept_line/_atuin_ai_question_mark_wrapperscaffolding.