Something like this should work for you. Sublime doesn’t allow you to set a custom name in the open_file method, but it does return a view and there is a set_name method on the view object that will do what you want. Calls to view methods are not available while the view is loading so I have created a new method called set_name which will check if the file is loading. If it is it will wait 10 milliseconds and check again. Do NOT set the number in the set_timeout call to 0, this will is most cases lock up Sublime!
class OpenFileNameCommand(sublime_plugin.WindowCommand):
def run(self):
file_path = {your_file}
view = self.window.open_file(file_path)
self.set_name(view, "This is a custom file!")
def set_name(self, view, name):
if (not view.is_loading()):
view.set_name(name)
else:
sublime.set_timeout(lambda: self.set_name(view, name), 10)
I Hope this helps!
P.S. this was tested on ST3 only, there may be a different solution in ST2.