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

Enable alt+c bash binding with version > 4 syntax. #2674

Conversation

lucasteligioridis
Copy link

What?

This patch introduces the same backwards compatible logic as the other
bash bindings, I believe the logic for alt+c was perhaps just missed in
a previous patch to use the bash > 4 syntax, which is cleaner and
actually resolves an issue with the terminal bash prompt overlapping in
a strange way / line wrapping. (with vi-mode enabled on bash)

This is mostly a cosmetic fix but also fixes another issue with the fzf
command exiting cleanly when aborted.

See some screenshots showing the issue I was having, too me way too
long to figure out that this was the issue. Full disclosure I'm not sure if
this will cause issues on bash versions < 4 or whether or not there was
something else in my configuration that was conflicting. Ultimately, this
resolved the issue you can see was occurring in the screenshots.

Broken / malformed prompt

Screen Shot 2021-11-30 at 10 38 29 pm

Screen Shot 2021-11-30 at 10 38 44 pm

After patch

Screen Shot 2021-11-30 at 10 43 37 pm

This patch introduces the same backwards compatible logic as the other
bash bindings, I believe the logic for alt+c was perhaps just missed in
a previous patch to use the bash > 4 syntax, which is cleaner and
actually resolves an issue with the terminal bash prompt overlapping in
a strange way.

This is mostly a cosmetic fix but also fixes another issue with the fzf
command exiting cleanly when aborted.
@junegunn
Copy link
Owner

Thanks, I'm seeing this issue where my prompt ($PS1) is not updated after changing directory. Any idea?

See https://asciinema.org/a/XMIFveAAEmIDlV7LLhyLlk23Y

@lucasteligioridis
Copy link
Author

Hmmm something i missed perhaps.
Let me take a look again and I'll push up a fix. Leave it with me for the moment.

Thanks for testing @junegunn, thought I checked this fine yesterday and saw that exact same issue. I'll reset my PS1 to something more basic to remove any of my own configuration out of the equation.

@lucasteligioridis
Copy link
Author

Ah yes I see the same issue, this is what I saw yesterday with my actual $PS1 not updating. 👍🏼

@lucasteligioridis
Copy link
Author

On a fair bit of research and testing, I don't think this is actually possible using the bind -x parameter, it's really the core of how READLINE works. There are a bunch of "hacky" ways to get this "almost" working, but it's probably not worth even worrying about to be honest and would add a bunch of extra code for not a huge amount of value. Was really just trying to cleanup the way the bash prompt handled the binding like the other commands, I'm super disappointed this can't be easily done in bash.

Ultimately there is no way for the prompt to re-evaluate correctly that I can see as it expects a user input / return carriage. As I see it that isn't possible with bind -x, you'd have to fall back onto macros to achieve this.

Appreciate checking this out and testing anyway ❤️

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.

None yet

2 participants