I have i3 keyboard shortcuts to write a new blog entry or note
~/.config/i3/config
bindsym $mod+J exec ~/projects/bins/today.sh ~/Documents/Journal/
bindsym $mod+B exec ~/projects/bins/today.sh ~/Documents/lecaro.me/src/
Mod + J
opens today's journal entry, and Mod + B
opens a blog post. I find it very comvenient, and even use it to open sublime and then look at some other files.
The issue with that is that the buffer is kept as an empty tab, and sublime asks me if I want to save it when I try to close it. I created a small plugin to stop asking to save empty buffers for files that don't exist on disk. All I needed to do was to extend sublime_plugin.EventListener in a python file placed in the ~/.config/sublime-text/Packages/User/
directory. Mistral AI struggled to follow my prompt so I ended up writing it by hand.
~/.config/sublime-text/Packages/User/dont_prompt_save_empty.py
import sublime
import sublime_plugin
import os.path
class NoSaveEmptyTabsListener(sublime_plugin.EventListener):
def on_load_async(self, view):
if view.file_name() and not os.path.isfile(view.file_name()):
view.set_scratch(True)
def on_init(self, views):
for view in views:
if view.file_name() and not os.path.isfile(view.file_name()):
view.set_scratch(True)
def on_modified_async(self, view):
if view.is_scratch() and view.size() and view.file_name():
view.set_scratch(False)
Edit on 2025-01-14 : added the on_init part to also mark empty documents as scratch when sublime starts up.