mcfly icon indicating copy to clipboard operation
mcfly copied to clipboard

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

Open asdf23 opened this issue 3 years ago • 3 comments

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 ~]$ 

asdf23 avatar Aug 28 '20 20:08 asdf23

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

cantino avatar Aug 28 '20 20:08 cantino

This is certainly an issue. Please reopen.

The problem is described here:

  • Get the contents of the current line, to be used in the search query
  • Invoke mcfly search (query) or insert the search query in the history file and invoke mcfly search

Bonus:

  • When cancelled, leave the terminal with the old current line, or contents of the search query

CreativeCactus avatar Oct 15 '20 10:10 CreativeCactus

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.

CreativeCactus avatar Oct 15 '20 10:10 CreativeCactus