class Utils::Editor

def activate

def activate
  if Array(config.vim_default_args).include?('-g')
    edit_remote("stupid_trick#{rand}")
    sleep pause_duration
    edit_remote_send('<ESC>:bw<CR>')
  else
    pstree = PSTree.new
    switch_to_index =
      `tmux list-panes -F '\#{pane_pid} \#{pane_index}'`.lines.find { |l|
        pid, index = l.split(' ')
        pid = pid.to_i
        if pstree.find { |ps| ps.pid != $$ && ps.ppid == pid && ps.cmd =~ %r(/edit( |$)) }
          break index.to_i
        end
      }
    switch_to_index and system "tmux select-pane -t #{switch_to_index}"
  end
end