Save tab status after switching tabs

Save the tab state after switching tabs, including selected items and focused item, and restore it when switching tabs after restarting. I could do it via script, but I'd prefer it integrated.