cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.87k stars 177 forks source link

When exiting (ESC) from mcfly search (or Ctrl+R) I see unwanted output #100

Open asdf23 opened 4 years ago

asdf23 commented 4 years ago

What I'm doing: Ctrl + R > ESC or myfly search > ESC

I expect the screen to return to how it looked before my last command. Instead I see:

[user1@myBox ~]$ #mcfly: 
[user1@myBox ~]$  mcfly search
[user1@myBox ~]$ 
cantino commented 4 years ago

As far as I know, this is unavoidable in bash. (Solutions welcome!) It doesn't happen in zsh or fish.

CreativeCactus commented 3 years ago

This is certainly an issue. Please reopen.

The problem is described here:

Bonus:

CreativeCactus commented 3 years ago

Nothing is unavoidable or impossible, it is only a matter of practicality for the hacks involved. In this case, it seems like it's only a small change.

With about 40 mins of searching and testing, I found that you can invoke functions using bind, is there some reason that this feature isn't being used? I couldn't find a bash version where bind was introduced, but I assume it is quite old, and in case we need to check for support, what's another nested if statement between friends?

By replacing this line with bind -x '"\C-r": "array=($READLINE_LINE); echo \#mcfly: ${array[0]} > $MCFLY_HISTORY ; mcfly search"' I was able to get the exact functionality described above.

I have made a PR here.