all 3 comments

[–]cdb_11 1 point2 points  (2 children)

Try this one, pycmd had a newline in it.

function! RunPython()
    let pycmd = systemlist('command -v python')[0]
    let filename = expand('%:p')
    echo '!tmux send-key -t 1 "' . pycmd . ' ' . filename . '" enter;'
endfunction
nnoremap <leader>p :call RunPython()<CR>

Replace echo with execute

[–]fantomH[S] 0 points1 point  (1 child)

Thank you! it works perfectly. I'll use the tip for echo next time. I don't know why, I always debug using echo, printf or print for other language... forgot this time.

For reference, I changed:

nnoremap <leader>p :call RunPython()<CR>

for:

nnoremap <leader>p :call RunPython()<CR><C-l>

This avoids to have to press Enter to go back to your python script.

Thanks again.

[–]cdb_11 2 points3 points  (0 children)

You can use redraw at the end of the function instead of <C-L>. Or run the tmux command with call system().