Since version 3.0, Safari has provided, in its History menu, Reopen Last Closed Window and Reopen All Windows From Last Session commands. These features let you easily reopen the last Safari window you closed, and reopen all windows that were open the last time you quit Safari, respectively. Each command also restores any tabs that were open within those windows.
But what about the single tab you just accidentally closed? The one you opened four hours — or even four days — ago, so it’s not easy to find in your history? Inexplicably, Safari has been missing the obvious counterpart those those commands: a way to reopen the last-closed tab. I can’t count the number of times I’ve seen requests for this capability.
It turns out that Safari 5 finally provides just such a feature — but it doesn’t appear to be documented, not even in Apple’s detailed list of new features and improvements. Thankfully, it’s simple — even obvious — to use: if you accidentally close a tab you didn’t mean to close, just press Command+Z, the Mac’s standard keyboard shortcut for Undo. The “lost” tab is immediately restored. (You can also use the Undo command in Safari’s Edit menu, which changes to Undo Closed Tab.)
My favourite part of this new feature — besides the fact that it exists, of course — is that it keeps track of the last tab you’ve closed in each window. So pressing Command+Z in Window A will restore a different tab than pressing the shortcut in Window B.