You know, what would be cool? If each file tab would somewhere show me the modification time of this file.
Show file modification time
The status bar is a more appropriate place to show that imo. Tabs are crowded.
Both of them can be done with plugin APIs already anyway.
Do you know if there is already a plug-in, which does this?
Well yeah, the status bar is definitely a good place. I didn’t actually mean on the tab when I said that. I just meant that the modification time should be shown somewhere when I click on a file tab.
No. I don’t claim it exists or it doesn’t. I just say it can be done via plugin APIs.
Here’s a simple implementation.
import datetime
import os
import sublime
import sublime_plugin
class ShowFileModifiedTimeListener(sublime_plugin.ViewEventListener):
def on_activated_async(self):
file = self.view.file_name()
try:
mtime = os.path.getmtime(file)
except:
mtime = 0
self.show_file_modified_time(self.view, mtime)
def show_file_modified_time(self, view, t):
if t == 0:
sublime.status_message("")
return
mdate = datetime.datetime.fromtimestamp(t)
view.set_status("mdate", mdate.strftime("mod: %Y/%m/%d %H:%M:%S"))
Add file date/time to status bar
Man, you are truly awesome I will try this when I have the chance.
Edit: I tried this and it just works magically. Thanks!
@jfcherng is there a way in this code snippet to control where exactly on the status bar this appears? currently the file modification date/time sits all the way on the lower left (before the line/column indicators). how can this be moved to after the line/column? or somewhere else far to the right on the status bar?
Status messages are displayed sorted alphabetically by their key name.
Line,Column is provided by core and can’t be moved.
As of ST4 you could however hide it (and replace it with a plugin), which would enable some more control about its location. An example can be found at Line count or percentage in status bar