Thursday, April 17, 2014

Sublime : Open CSV in Open Office Excel

Create File Default/open_in_open_office
place below contents

import sublime, sublime_plugin, subprocess, os
class OpenInOpenOfficeCommand(sublime_plugin.TextCommand):

def run(self, edit):
if self.view.file_name():
os.chdir("/Applications/OpenOffice.app/Contents/program")
subprocess.Popen(["./soffice", self.view.file_name()])

def is_visible(self):
return self.view.file_name() and (self.view.file_name()[-4:] == ".csv")


Update File Default->Context.sublime-menu
{ "command": "open_in_open_office", "caption": "Open in Open Office" }
references
http://stackoverflow.com/questions/16147073/adding-custom-menus-in-sublime-text http://stackoverflow.com/questions/636561/how-can-i-run-an-external-command-asynchronously-from-python http://stackoverflow.com/questions/431684/how-do-i-cd-in-python https://docs.python.org/2/library/subprocess.html

No comments:

Post a Comment