Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Created October 31, 2017 16:50
Show Gist options
  • Select an option

  • Save hoelzro/b5fb7deeef25f16656a88b81ad6cf4eb to your computer and use it in GitHub Desktop.

Select an option

Save hoelzro/b5fb7deeef25f16656a88b81ad6cf4eb to your computer and use it in GitHub Desktop.
A dumb vimscript "workbench" for sending queries to a MySQL shell in another tmux pane
function! SendSelectionToMySQL(start_line_no, end_line_no)
let lines = getline(a:start_line_no, a:end_line_no)
let index = 0
for line in lines
call system('tmux send-keys -l -t:.- ' . shellescape(line))
if index == len(lines) - 1
call system('tmux send-keys -t:.- ' . shellescape('\;') . ' Enter')
else
call system('tmux send-keys -t:.- Enter ')
endif
let index = index + 1
endfor
endfunction
command! -range SendSelectionToMySQL :call SendSelectionToMySQL(<line1>, <line2>)
nnoremap <F5> vip
vnoremap <F5> :SendSelectionToMySQL<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment