I would like to open a new tab in Terminal with custom scrollback history. The primary use-case is to "fork" an existing tab such that both tabs contain the same scrollback history, but more generally I would like to have some custom scripts save and restore Terminal sessions.
I know about the history restore functionality already in Terminal but it doesn't suit my needs; the main one being that I have a system built around the
script command and some
zsh hooks to save history and output for all terminal sessions for later auditing purposes (recalling changes that I've made).
I would now like to switch to use
osascript to save the history and on restoring sessions later to match up the new session with its prior one- in a way, implementing long-term, persistent sessions. I've had Terminal's saved sessions lose their data too many times that I am working around it.