Reading Safari's LastSession.plist

Is it just me, or does everyone see this message when quitting Safari:

"Do you really want to Quit Safari? You have a 400 Windows open that contain a bajillion tabs!"

Yeah, I can keep going down the rabbit-hole of links as good as the next person. But that doesn't mean I don't ever restart my machine (on purpose, or, thanks to unstable code). When Safari gained the ability to "Reopen all Windows from Last Session," I was extremely pleased. Let's face it: Safari can sometimes die unexpectedly.

Safari stores all of these windows and URLs in ~/Library/Safari/LastSession.plist. I rely on it a lot.

Because I want to trim down the number of tabs I have open (honestly: I can't be paying attention to all of them, and, there is one in there that made Safari crash in the first place), I'll try to start fresh, rather than reopen all windows. Also, I don't want a crashy tab popping back into the mix. But I do want to know what URLs I had open. Enter readLastSession, a Python script.

For now, I've just attached it here - it may go up on github or something soon. Just download it and run it. Use the -h flag for help. It can either write each URL to the screen or out to .webloc files. Or both - your choice.

Enjoy, and let me know if you use it, and/or want changes and improvements.


Filename/TitleSize
readLastSession.2.78 KB