cantino / mcfly

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

mcfly does not parse and use HISTTIMEFORMAT #246

Open alespg opened 2 years ago

alespg commented 2 years ago

Hi! i love this tool, but i have found this annoying issue:

After using mcfly to recover a command, if you use the classic up arrow key to navigate through history, first result is the last command used, but next is the whole mcfly intarface and next, it breaks. Is this a known issue? is there any way to avoid it?

Thank you!

cantino commented 2 years ago

I've never seen this before. What shell are you using?

alespg commented 2 years ago

Hi! thank you for answering.

I am using bashrc.

I have been testing more and it happens when it reaches the session history limit.

If i open the terminal and write several commands, then the cursor keys scroll until the first command i wrote and then, it shows the mcfly history, everything as a single command.

If i press up before writting anything in the terminal, it shows the mcfly history as well.

The .bash_history file is correct, but it doesnt work properly.

cantino commented 2 years ago

I'm sorry, I'm not sure why that's happening.

alespg commented 2 years ago

ok, thank you anyway!

josep-pla-jt commented 2 years ago

I've exactly the same issue, seems weird but sometimes last commands are not being shown by mcfly, not sure why

BackSpace54 commented 1 year ago

Hi,

it seem i've found the problem (i'm having the same issue with up arrow key on various distro). Oh My Bash introduces the parameter HIST_STAMPS in .bashrc file, full added lines are below : _Uncomment the following line if you want to change the command execution time stamp shown in the history command output. The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" HISTSTAMPS="mm/dd/yyyy"

So if you uncomment HIST_STAMPS McFly has troubles with history file that content dates and have the exact problem describes above.

To resolve this comment HIST_STAMPS and the problem is gone (at least for me it does the job). Fyi Oh My ZSH also use a HIST_STAMPS parameter, i don't know if the same problem occurs.

Edit: strange thing remaining in Oh my bash + McFly, the 'ls' and 'clear' commands are not kept (?) Edit 2: to resolve the issue with arrow key up you also need to clean Mcfly temporary files in /tmp remove all mcfly.\<random characters> files then close all terminals

Bye.

BackSpace54 commented 1 year ago

Hi again,

after testing the best workaround to this issue seems to be to delete all mcfly.\<random characters> files located in /tmp by adding rm -f /tmp/mcfly.* at the end of the .bashrc file.

Bye.

eggbean commented 1 year ago

I had the same issue with very broken and frustrating behavior, until I read @BackSpace54's comment above. I had to comment-out my [standard bash] HISTTIMEFORMAT variable which I had added to include timestamps. Would be good if MyFly could deal with different history formats by checking the HISTTIMEFORMAT variable so that it knows what to ignore. Mine was HISTTIMEFORMAT="%d/%m/%y %T ".

cantino commented 1 year ago

Thank you for identifying the problem. I agree that, ideally, mcfly would parse and use HISTTIMEFORMAT.

danwilliams commented 11 months ago

I just hit this issue today 🙁 Unfortunately I ran headlong into it as I tapped up arrow a couple of times and hit enter without really looking at what was happening, and it ran a whole load of previous commands. I spent the next half hour carefully trying to work out what it had re-run, and cleaning up the mess.

Even worse is that it somehow nuked everything in my history file... 😢

Storing timestamps against history entries is standard Bash, and so this really should be supported.

@cantino is anyone working on this? If not, I might be able to find some time to look into a fix 🙂 I love the Ctrl-R behaviour, but breaking up-arrow makes it unusable.

danwilliams commented 11 months ago

I found this related issue also: https://github.com/cantino/mcfly/issues/58

Probably both could be solved at once.

cantino commented 10 months ago

I don't think anyone is working on this.