I wish there was a (Jupyter) notebook-like interface in shells so only the final set of commands is saved in the history after a trial-and-error/refinement cycle
https://blog.atuin.sh/atuin-desktop-runbooks-that-run/
Im not sure if its entirely what you are asking about though
Shoot me an email if you fancy trying it
Ellie at Atuin dot sh