Where does Sublime Text store its un-saved windows?

I'm using Sublime Text as a notepad and usually I've plenty of un-saved files which usually are re-open after reboot or crash, but I'm afraid to lose them (which happened few times).

Where (in which folder/file) does Sublime Text store these temporary files, so I can do some periodic session backups?


Where does Sublime Text store its un-saved windows?

This depends on which operating system your are using.


OSX

Sublime Text 3:

~/Library/Application Support/Sublime Text 3/Local/Session.sublime_session

Sublime Text 2:

~/Library/Application Support/Sublime Text 2/Settings/Auto Save.sublime_session

I'm wondering if there is a location Sublime puts temporary files? I just lost a WP theme I was working on due to MacOSX blundering, wondering if I can get any of the files I was working on back from Sublime temp files.

...

Sublime Text will save auto save information to ~/Library/Application Support/Sublime Text 2/Settings/Auto Save.sublime_session, but it does so on a regular basis, and the chances are it's overwritten by now, unfortunately.

Source Temporary Files location?


Windows

For the settings folder you could look for a unique file using:

F:\>dir license.sublime_license /s /b  

For XP that would return:

F:\Documents and Settings\user\Application Data\Sublime Text 2\Settings\License.sublime_license

Alternatively:

  • Open sublime and go to preferences > browse packages.
  • Then to the parent directory and you'll see the settings subdirectory.

XP

C:\Documents and Settings\user\Application Data\Sublime Text 2\Settings\Auto Save Session.sublime_session

Windows 7

Sublime Text 2:

C:\Users\user\AppData\Roaming\Sublime Text 2\Settings

Sublime Text 3:

C:\Users\user\AppData\Roaming\Sublime Text 3\Local

(section added by barlop)


Windows 7 64bit, Sublime Text 3 saves its working session (including the contents of tabs that were unsaved when the application was closed) to:

C:\Users\{username}\AppData\Roaming\Sublime Text 3\Local\Session.sublime_session


In Linux, Sublime text 3 unsaved content is stored in ~/.config/sublime-text-3/Local/Session.sublime_session


For Linux

In the Mint distro, the complete file names/paths opened for each tab of Sublime Text 3, can be accessed with this Bash line:

cat $HOME/.config/sublime-text-3/Local/Auto\ Save\ Session.sublime_session |grep "\"file\":" |sed 's/^[[:space:]]*//g' |sed 's/^\"file\"\: \"//g' |sort -u | sed 's/[\",]*//ig'

NOTE: If you use Session.sublime_session instead of "Auto Save Session.sublime_session", you can get different results, with missing tabs/files.

Anyway, this is not 100% reliable, but will get you started. I'm sure you can improve this ugly line, so feel free to comment.

Explanation:

  • 1st sed removes leading white space due to JSON keys
  • 2nd sed remove the "file": " part
  • sort -u (unique) remove filename duplicates
  • 3rd sed remove trailing white space.