Open hongyi-zhao opened 2 months ago
Ah interesting, thank you for opening this issue! Does this reproduce reliably for you? Or only sometimes? I can't seem to reproduce this, so I'm wondering if this is some sort of race condition.
It seems that I can reproduce this reliably, as shown below:
I wonder if there is any way to debug this problem conveniently.
BTW, as you can see, the recorded two timestamps for the same operation are inconsistent. Therefore, I suspect there is something wrong with this timestamp-recording logic.
Ah perfect, thank you for that! I can now reproduce this and am working on a fix in #217. I'll keep you updated as I look into this. :)
The above PR doesn't work, see below for my test and comment: https://github.com/ddworken/hishtory/pull/218#issuecomment-2156400014
Ah interesting, thank you for testing this and letting me know! Just to confirm, this is with the latest version of hishtory installed, right? Can you share with me:
hishtory status
(with your secret key redacted)Ah interesting, thank you for testing this and letting me know! Just to confirm, this is with the latest version of hishtory installed, right?
Yes.
Can you share with me:
1. The output of `hishtory status` (with your secret key redacted)
$ hishtory status
hiSHtory: v0.Unknown
Enabled: true
Secret Key: xxx
Commit Hash: Unknown
2. What version of bash you're using?
$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Hmm, two follow-up questions as I continue to look into this:
v0.Unknown
). Is that correct?Hmm, I'm a bit stumped by this and am still struggling to reproduce this. I'm running Ubuntu 22.04 with bash 5.1.16(1)-release
(the same as you) and with the latest version of hishtory I'm unable to reproduce this. My best guess is that something has gone wrong with how you're updating/installing hishtory. Can you check whether you're running with the latest shell config via declare -f __hishtory_precommand
, it should show something like:
# declare -f __hishtory_precommand
__hishtory_precommand ()
{
if [ -z "${HISHTORY_AT_PROMPT:-}" ]; then
return;
fi;
unset HISHTORY_AT_PROMPT;
HISHTORY_START_TIME=`hishtory getTimestamp`;
CMD=`history 1`;
if ! [ -z "CMD " ]; then
if [[ "$CMD" != "$LAST_PRESAVED_COMMAND" ]] && [[ "$CMD" != "$LAST_SAVED_COMMAND" ]]; then
( hishtory presaveHistoryEntry bash "$CMD" $HISHTORY_START_TIME & );
fi;
fi;
LAST_PRESAVED_COMMAND=$CMD
}
See below:
werner@x13dai-t:~$ declare -f __hishtory_precommand
__hishtory_precommand ()
{
if [ -z "${HISHTORY_AT_PROMPT:-}" ]; then
return;
fi;
unset HISHTORY_AT_PROMPT;
HISHTORY_START_TIME=`hishtory getTimestamp`;
CMD=`history 1`;
if ! [ -z "CMD " ]; then
( hishtory presaveHistoryEntry bash "$CMD" $HISHTORY_START_TIME & );
fi
}
Ah, that does seem to show that you don't have the latest version of hishtory install. You're missing the updated bit here.
How are you building it locally? go build; ./hishtory install
should be enough to update the file at ~/.hishtory/config.sh
to have the updated definition of __hishtory_precommand
. As long as that is true, then restarting your terminal/shell should work fine.
This time, the problem has been fixed and I see the same __hishtory_precommand
as yours:
werner@x13dai-t:~$ declare -f __hishtory_precommand
__hishtory_precommand ()
{
if [ -z "${HISHTORY_AT_PROMPT:-}" ]; then
return;
fi;
unset HISHTORY_AT_PROMPT;
HISHTORY_START_TIME=`hishtory getTimestamp`;
CMD=`history 1`;
if ! [ -z "CMD " ]; then
if [[ "$CMD" != "$LAST_PRESAVED_COMMAND" ]] && [[ "$CMD" != "$LAST_SAVED_COMMAND" ]]; then
( hishtory presaveHistoryEntry bash "$CMD" $HISHTORY_START_TIME & );
fi;
fi;
LAST_PRESAVED_COMMAND=$CMD
}
go build; ./hishtory install
should be enough to update the file at~/.hishtory/config.sh
to have the updated definition of__hishtory_precommand
.
Though ./hishtory install
works, but there is no such a subcommand in the help:
werner@x13dai-t:~/Public/repo/github.com/ddworken$ hishtory -h |grep install
uninstall Completely uninstall hiSHtory and remove your shell history
I'm using the latest GitHub version of
hishtory
on Ubuntu 22.04.4 LTS.I noticed that after I issued the following command:
werner@x13dai-t:~$ hishtory config-set displayed-columns CWD Command ExitCode timestamp
There will be two duplicate entries with the same timestamp be added to the history log file of
hishtory
, which seems unreasonable, as shown below:Regards, Zhao