Skip to content
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

Clear RBUFFER when accepting output from atuin #545

Merged
merged 1 commit into from
Sep 25, 2022

Conversation

c-14
Copy link
Contributor

@c-14 c-14 commented Sep 25, 2022

Since we pass $BUFFER to atuin search, retaining RBUFFER (the part of the buffer to the right of the cursor) on accepting a history replacement probably doesn't make sense. The advantage of setting RBUFFER and LBUFFER separately instead of setting BUFFER is that the cursor is positioned after the end of LBUFFER instead of remaining where it was before atuin was called.

Alternatively, _atuin_search() could pass $LBUFFER to atuin instead of $BUFFER which would allow the widget to replace parts of command lines (such as the initial parts of a shell pipeline), but I would prefer the default to replace the whole command line from the history.

A widget that only replaces parts of command lines could be added separately if there's interest in it, though users could always just add it themselves (I'm not sure how many users would want such a feature).

Since we pass $BUFFER to atuin search, retaining RBUFFER (the part of
the buffer to the right of the cursor) probably doesn't make sense. The
advantage of setting RBUFFER and LBUFFER separately instead of setting
BUFFER is that the cursor is positioned after the end of LBUFFER instead
of remaining where it was before atuin was called.
Copy link
Member

@ellie ellie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! 🚀

A widget that only replaces parts of command lines could be added separately if there's interest in it, though users could always just add it themselves (I'm not sure how many users would want such a feature).

Would you be able to explain a workflow or use case where this might be useful?

@ellie ellie merged commit f93da45 into atuinsh:main Sep 25, 2022
@c-14 c-14 deleted the fix/zsh-rbuffer branch September 25, 2022 16:24
@c-14
Copy link
Contributor Author

c-14 commented Sep 25, 2022

I was thinking something like a curl <endpoint> | jq <query> pipeline in which one might want to replace e.q. the call to curl with a call to a different endpoint (potentially with other curl options) that you've used previously and would be in atuin's history, but would then want to keep the same jq query at the end.

I don't think it would be useful to the point that very many people would make use of it though. Replacing the entire command line with the match from atuin seems a lot more generally useful.

@ellie ellie mentioned this pull request Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants