Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class open_in_vim(Command):
- """:open_in_vim <filename>
- Opens a file in a new vim tab, if vim is not already running, opens vim.
- """
- def execute(self):
- if self.arg(1):
- _open(self.rest(1))
- else:
- _open(self.fm.thisfile.path)
- def _open(file_name):
- regex = re.compile('(^|/)*nvim$')
- vim_pane = filter(regex.search, check_output(['tmux', 'list-panes', '-F', ''#{pane_id} #{pane_current_command}'']))[0].split(' ')[0]
- if vim_pane:
- check_output(['tmux', 'send-keys', '-t', vim_pane, 'Escape', 'Escape', ':tab', 'Space', 'drop', 'Space', file_name, 'Enter'])
- else:
- check_output(['tmux', 'split-window', '-h', '-p', '75', '-c', ''#{pane_current_path}'', '"nvim {}"'.format(file_name)])
- def tab(self, tabnum):
- return self._tab_directory_content()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement