cantino / mcfly

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

feat/ Fix for issue 100, removes terminal debris #105

Closed CreativeCactus closed 3 years ago

CreativeCactus commented 3 years ago

Fixes https://github.com/cantino/mcfly/issues/100

I don't know enough about the first bind if set -o | grep "vi " | grep -q on passes, but I'm sure someone who knows why this condition exists can copy my pattern. :)

cantino commented 3 years ago

Thanks @CreativeCactus, this looks like a great start to a solution! However, on my computer, it echos #mcfly: to the history and never includes the current command line. It looks like array[0] is always blank for me in bash (3.2) on OS X.

CreativeCactus commented 3 years ago

It looks like bash <4 has no READLINE_LINE, so we will either need a version check, or find another way to get the current line in the bind handler.

Also, ${array[0]} should have been ${array[@]}, my bad.

CreativeCactus commented 3 years ago

@cantino I've added a version check to use the $READLINE_LINE trick.

For bash<4, you might be able to use those control characters to move up a line and clear it? It's not as elegant, but it might be worth trying if you have not already. Maybe even bind -x '"C-r": "printf some control characters".

Unfortunately I don't have much time to experiment this week, but this branch should now be suitable to merge (pending review) as a fix for bash>=4 users.

cantino commented 3 years ago

Sorry for the delay on this, I'll need to test it out on a virtual machine when I have a chance. It's too bad that it needs to version check bash, but I guess that's unavoidable.

cantino commented 3 years ago

I've rebased and updated this in #113