cantino / mcfly

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

Globally set HISTFILE variable with Fish results in fish_history corruption when running a bash subshell #199

Closed btglr closed 2 years ago

btglr commented 2 years ago

As can be seen in this issue: https://github.com/fish-shell/fish-shell/issues/8349, 'corruption' of the fish_history file occurs when using mcfly with Fish. Due to HISTFILE being set globally with set -gx: https://github.com/cantino/mcfly/blob/2daa339f0ee52c5e7b17321c3e64d1fe715d8d6d/mcfly.fish#L12 running bash inside a Fish shell using this plugin causes the bash shell to inherit the HISTFILE variable which results in it being set to ~/.local/share/fish/fish_history instead of ~/.bash_history. Subsequently, bash starts writing in the fish_history file which uses a different format and in turn breaks the history until manually fixed.

cantino commented 2 years ago

Thanks @btglr. I don't use Fish. What's the best way to fix this?

btglr commented 2 years ago

Is there a reason you need HISTFILE to be set globally? I added set -e HISTFILE (which erases the variable) to my Fish config as recommended in the issue I linked and everything still seems to work fine in regards to your plugin. Fish itself doesn't need that variable to be set.

cantino commented 2 years ago

I suspect that's cruft left over from the bash implementation that's not needed for fish.

cantino commented 2 years ago

As I think about it, this issue is likely to occur whenever you call one shell (without mcfly init code) inside a shell with mcfly init code. Not sure what the best solution is.

cantino commented 2 years ago

Do you mind seeing if https://github.com/cantino/mcfly/pull/204 fixes this for you?

btglr commented 2 years ago

Do you mind seeing if #204 fixes this for you?

I just tried it and it does fix the problem. Thanks!

cantino commented 2 years ago

Great, thanks for checking!

cantino commented 2 years ago

Released in 0.5.10.