cantino / mcfly

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

Prevent cluttering up the buffer in Bash 4+ #113

Closed cantino closed 3 years ago

cantino commented 3 years ago

Thanks to @CreativeCactus for the methodology. I think this works, but it'd be helpful if users of bash could test it. I use zsh these days.

Things to test:

@JamJar00

JamJar00 commented 3 years ago

I can probably have a look, I think I've deleted my linux VM with all the rust build tools on though!

JamJar00 commented 3 years ago

Tested in WSL 1 running bash 4.4.19(1)-release and this all seems to be working.

I can theoretically test on an Ubuntu VM as well but it'll take me a little longer to install everything!

JamJar00 commented 3 years ago

For clarity, it's still outputting:

$ #mcfly: whatever you type
$  mcfly search

But I don't think the PR is trying to solve that.

Neither of those lines are in the bash history, just on the console.

CreativeCactus commented 3 years ago

For clarity, it's still outputting:

$ #mcfly: whatever you type
$  mcfly search

But I don't think the PR is trying to solve that.

This PR should solve that. It might be that you are using bash <4, or some other shell. The bind -x approach writes #mcfly: directly to the $MCFLY_HISTORY file for compatibility, but really it could use any mechanism to pass history to mcfly. Doing it this way does prevent writing to the terminal, and therefore does not depend on $HISTCONTROL to hide it from bash history.

JamJar00 commented 3 years ago

This PR should solve that. It might be that you are using bash <4, or some other shell. The bind -x approach writes #mcfly: directly to the $MCFLY_HISTORY file for compatibility, but really it could use any mechanism to pass history to mcfly. Doing it this way does prevent writing to the terminal, and therefore does not depend on $HISTCONTROL to hide it from bash history.

You are absolutely correct, I forgot to source in my bashrc after I built it, looks like I just tested normal mcfly 🤦‍♂️

Everything seems to be working alright for me!

cantino commented 3 years ago

Thanks for testing folks!

cantino commented 3 years ago

Released in 0.5.2