mcfly
mcfly copied to clipboard
When exiting (ESC) from mcfly search (or Ctrl+R) I see unwanted output
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 ~]$
As far as I know, this is unavoidable in bash. (Solutions welcome!) It doesn't happen in zsh or fish.
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 invokemcfly search
Bonus:
- When cancelled, leave the terminal with the old current line, or contents of the search query
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.