We now have to fiddle with Tmux just a tiny bit more, but it's fairly painless, and once we are done we are free to be creative. Fundamentally, we should call the cmd_entry
initialization hook in server.c
just before we forget about it:
#ifdef HAVE_PYTHON
Py_InitializeEx (0);
tmux_init_cython ();
#endif
server_loop();
#ifdef HAVE_PYTHON
Py_Finalize ();
#endif
Now that this is done, we need to make sure we add the cmd_entry_python
extern declaration to tmux.h
:
extern const struct cmd_entry cmd_wait_for_entry;
#ifdef HAVE_PYTHON
# include "cmdpython.h"
#endif
Finally, add this to cmd_table
:
const struct cmd_entry *cmd_table[] = {
&cmd_attach_session_entry,
&cmd_bind_key_entry,
&cmd_break_pane_entry,
…
&cmd_wait_for_entry,
&cmd_entry_python,
NULL
};
Now that this is done, I think we're good to go—let's test out this baby. Compile Tmux with the following:
$ ./configure –enable-python $ make $ ./tmux -vvv $ tmux: C-b :python $ tmux...