Closed vext01 closed 11 months ago
Thank you for trying to do something, but I have to say that addressing this issue is far harder than it may seem. I tried to implement a similar option myself about two years ago and then gave up.
The current design principle of yash's history is that all shell sessions share the same in-memory copy of the history file. This ensures the integrity of the history saved in the file. If sessions kept different in-memory history data, it would be much more difficult for each session to interact with the file without disturbing other session's interaction with the file.
Based on the principle, any access to the history file is designed to be done in the following manner:
$HISTSIZE
, the shell refreshes the file, that is, the shell clears the file and rewrites the whole in-memory history back to the file, effectively performing garbage collection in the file. During the rewrite to the file, the shell updates the revision number written in the file header to tell other sessions that the file has been refreshed.So, a simple approach as proposed in this pull request would not be viable as it would break the existing refreshing mechanism described above.
OK.
I'm finding that having the shared history is absolutely necessary for good-quality shell suggestions, but I'm also finding the behaviour of the up cursor key being frustrating (and potentially dangerous).
Closing this for now then. Thanks
This is a quick attempt to address one of the suggestions for https://github.com/magicant/yash/issues/25.
This implements the first option only. Is this the kind of thing we want?
If we like this, I think we'd also want a builtin and/or bindable to force reread the history, for those instances where you really do want the history from another shell.
(I notice that you are already using advisory locking on the history file, so you could probably implement something better, where history from other shells is inherited immediately, but the current shell's history are prioritised. The change here however is much simpler)
What do you think?