def attach_nvim(self): Utility.run_command("tmux split-window -h 'NVIM_LISTEN_ADDRESS=/tmp/nvim nvim'") while True: try: time.sleep(1) nvim = attach('socket', path='/tmp/nvim') except: continue break self.nvim = nvim
def open_browser(self, task): urls = [] if Utility.is_url(task.description()): urls.append(task.description()) possibles = [ v[u'description'] for v in task.annotations() if Utility.is_url(v[u'description']) ] urls.extend(possibles) for url in urls: Utility.run_command('open -a "Google Chrome" %s' % url)
def task_note(self, task): if not self.nvim: self.attach_nvim() if not os.path.isdir(expanduser(self.note_folder)): os.mkdir(expanduser(self.note_folder)) note_file = expanduser(self.note_folder + task.uuid() + ".markdown") if not os.path.isfile(note_file): with open(note_file, 'w+') as fh: header = "# " + task.description() fh.write(header) # Annotate the task to show that it has notes now. Utility.run_command("task %i annotate Notes" % task.id()) # either capture error or write note before changing buffer try: self.nvim.command("e " + note_file) except: self.nvim.command("w") self.nvim.command("e " + note_file)
def shell_done(self, content): Utility.run_command("tmux split-window '%s'" % content)
def command_done(self, content): Utility.run_command('task ' + content) self.refresh()
def task_note(self, task): Utility.run_command("tmux split-window 'tasknote %i'" % task.id())
def copy_notes(self, task): notes = [note[u'description'] for note in task.annotations()] Utility.write_to_clipboard("\n".join(notes))
def copy_description(self, task): Utility.write_to_clipboard(task.description())