Hello.
Thanks Larry for the clear explanation, this things are hard for me to explain.
These are fundamentally incompatible goals. Bash and zsh will not cooperate with each other for purposes of (avoiding) overlapping writes, the timestamp formats are incompatible, and the zsh history is stored "metafied" -- it is not a plain text file. That also explains this:
that after running this script, some special characters becomes 'weird' into the *.bash_history *viewing. With weird i mean things like *#º *and* #º *,which fortunately are not present in the terminal history (the commands are properly shown in there).
About the timestamps, i do not use those, so i think that would
not be a problem. I have seen, when the trying some options which
broke the history file (truncated it somehow), that there was some
kind of timestamp in the 2 last commands, but they are not present
in the .bash_history now. I think that the timestamp is disabled
on my side, and that's why i do not see it.
It makes sense to me now that sharing the history file for both
shells does not make sense and that would be causing those 'funny'
characters into the .bash_history file. Those ones, on the
other hand, display correctly in the zsh shell, when looking
through the history. Besides that, should i expect any other kind
of trouble if continuing like this? i have been a while in bash
and almost all my history lines are written that way.
HIST_EXPIRE_DUPS_FIRST
I think this one is not what i want, this will 'prune' the history when some kind of limit on the history lines is reached. I just want to keep my history file as clean as possible, but i also keep it long( HISTSIZE=2000000 , because i do not want to lose lines).
My approach to this would be to use "fc -p" to point to a new history file with setopts as appropriate from the above, pull the HISTFILE into that with "fc -R", write it out again with "fc -W", then move that to the desired history file with appropriate locking (which you can probably do by calling "fc -P" to switch back to the original history and then cycling -R/-W again). If you write that as a zsh script you can invoke it from bash to clean up bash's history as well, with the timestamp caveat. I'm not at my usual computer right now so not going to test details, I'll chime in again later if things seem to be going awry.
I do not understand how implement this, and what would be the difference about the previous idea of the trap command. I will appreciate if you can elaborate about this when you can.
Bluey.