duplicated history entries at the same timestamp
0
votes
0
answers
126
views
For some time I had an issue with my
history
using GNU bash
(version 4 and 5) where commands appeared in duplicates. I assumed this was due to the fact that in my .bashrc
I had the following line:
PROMPT_COMMAND="history -a; history -n; $PROMPT_COMMAND"
and since I'm using terminal multiplexers (screen
and/or tmux
) the above mentioned command gets executed several times (therefore echo $PROMPT_COMMAND
results in history -a; history -n; history -a; history -n;
In some situations (especially when doing stuff concomitantly on different panes/windows/frames/buffers) the last command I entered was stored twice or even more often in my ~/.bash_history
. This led to entries like the following:
#1596110297
yadm list -a | xargs -t ls -l
yadm list -a | xargs -t ls -l
Needless to say, this is pretty annoying. I hoped I found a fix for the issue by changing the command to PROMPT_COMMAND="history -a; history -n
but this did not solve it.
Any ideas why that is the case and what I could do get rid of it?
---
Disclaimer: I posted parts of this question at https://unix.stackexchange.com/questions/604842/grep-for-lines-not-after-a-pattern (since I thought the above mentioned solution would work and I therefore only wanted to only get rid of the duplicated entries).
Asked by n0542344
(416 rep)
Aug 24, 2020, 12:09 PM
Last activity: Aug 24, 2020, 10:57 PM
Last activity: Aug 24, 2020, 10:57 PM