Skip to content

Instantly share code, notes, and snippets.

@bouzuya
Created February 9, 2013 09:34
Show Gist options
  • Select an option

  • Save bouzuya/4744701 to your computer and use it in GitHub Desktop.

Select an option

Save bouzuya/4744701 to your computer and use it in GitHub Desktop.
function! s:insert_tmux_buffer()
let buffers = split(system('tmux list-buffers'), '\n')
if empty(buffers)
return
endif
let buffers_origin1 = map(buffers,
\ 'substitute(v:val, ''\V\^\d\+'', ''\=submatch(0) + 1'', '''')')
call insert(buffers_origin1, 'tmux list-buffers', 0)
let selected_index = inputlist(buffers_origin1) - 1
if selected_index >= 0
let buffer = system(printf('tmux show-buffer -b %d', selected_index))
call append('.', split(buffer, '\n'))
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment