christoomey / vim-tmux-runner

Vim and tmux, sittin' in a tree...
MIT License
291 stars 37 forks source link

Protect against killing the wrong background window #3

Open christoomey opened 11 years ago

christoomey commented 11 years ago

Since the KillDetachedRunner command currently does not use the window title it is possible for it to get out of sync with the window numbers and inadvertantly kill a window it does not own. This would be sad.

function! s:Windows()
    let window_descriptions = split(s:SendTmuxCommand("list-windows"), '\n')
    let windows = {}
    for line in window_descriptions
        " echom line
        " 1: vim [185x48] [layout 3adf,185x48,0,0] (active)
        " 2: zsh [185x48] [layout 3adf,185x48,0,0]
        let window_pattern = '\v(\d\+): (.*) \[.*\] \[.*\]'
        let window_details =  matchlist(line, window_pattern)
        echom window_details[1]
        " echom join([window_details[0], window_details[1]])
        " return {'width': pane_info[1], 'height': pane_info[2]}
    endfor
endfunction
command! VtrWindowDetails :call s:Windows()
nmap ,wn :VtrWindowDetails<cr>