Hi, So it's been a while. Here's an updated version of hook support.
For those of you wanting to play along at home, please see: https://github.com/ThomasAdam/tmux/tree/ta/new-hooks Some of it might still be rough around the edges; I'm planning on ironing that out over the next few days. Since I've not included any man page updates, as a reminder on how to use this, here's an example: set-hook -g 'before-new-window' 'run "~/bin/something #{window_index}"' This sets a global hook which runs before any neww command happens. Similarly, session-based hooks can also be set up: set-hook -tSESSION_NAME .... Note that all hooks are run withint the context of the hooked command. So for example, the following command would force hooked commands that /didn't/ set their own -t/-s flags, to use session 1: neww -t 1: Nicholas, I know we've spoken a little bit about this, here's some things to consider: * What happens about hooked commands inside load_cfg() -- that will generate an error because the contexts will be NULL. * I'm doing magical trickery (tm) with hooked contexts; and hence each command which runs as a hook action gets its own cmd_prepare() called. Unlike in previous discussions, it's not enough to assume that the hooked command can set up the appropriate context for all commands, because not all of those commands might provide them. I would _really_ appreciate user testing on this, so please, shunt this towards your friends or people who've been interested in this, and if it breaks, send me a corefile, please! Any questions, do please ask. Kindly, -- Thomas Adam Thomas Adam (3): Introduce prepare mechanism for commands Add hooks infrastructure Commands: Make use of prepare Makefile.am | 3 ++ cmd-attach-session.c | 11 +++-- cmd-bind-key.c | 3 +- cmd-break-pane.c | 9 ++-- cmd-capture-pane.c | 7 ++-- cmd-choose-buffer.c | 9 ++-- cmd-choose-client.c | 10 +++-- cmd-choose-tree.c | 22 ++++++---- cmd-clear-history.c | 11 ++--- cmd-clock-mode.c | 10 ++--- cmd-command-prompt.c | 7 ++-- cmd-confirm-before.c | 7 ++-- cmd-copy-mode.c | 8 ++-- cmd-delete-buffer.c | 3 +- cmd-detach-client.c | 28 +++++++++---- cmd-display-message.c | 42 +++++++++++++------ cmd-display-panes.c | 10 ++--- cmd-find-window.c | 9 ++-- cmd-has-session.c | 11 +++-- cmd-if-shell.c | 34 ++++++++++----- cmd-join-pane.c | 31 ++++++++++---- cmd-kill-pane.c | 10 +++-- cmd-kill-server.c | 6 ++- cmd-kill-session.c | 8 ++-- cmd-kill-window.c | 12 +++--- cmd-list-buffers.c | 3 +- cmd-list-clients.c | 14 +++---- cmd-list-keys.c | 6 ++- cmd-list-panes.c | 25 ++++++++--- cmd-list-sessions.c | 3 +- cmd-list-windows.c | 18 ++++++-- cmd-load-buffer.c | 3 +- cmd-lock-server.c | 28 +++++++++---- cmd-move-window.c | 33 +++++++++++---- cmd-new-session.c | 6 ++- cmd-new-window.c | 25 ++++++++--- cmd-paste-buffer.c | 10 +++-- cmd-pipe-pane.c | 8 ++-- cmd-queue.c | 59 ++++++++++++++++++++++++++ cmd-refresh-client.c | 7 ++-- cmd-rename-session.c | 8 ++-- cmd-rename-window.c | 9 ++-- cmd-resize-pane.c | 8 ++-- cmd-respawn-pane.c | 9 ++-- cmd-respawn-window.c | 8 ++-- cmd-rotate-window.c | 8 ++-- cmd-run-shell.c | 17 ++++---- cmd-save-buffer.c | 6 ++- cmd-select-layout.c | 17 ++++---- cmd-select-pane.c | 31 ++++++++++---- cmd-select-window.c | 52 +++++++++++++++++------ cmd-send-keys.c | 15 ++++--- cmd-set-buffer.c | 3 +- cmd-set-environment.c | 8 ++-- cmd-set-hook.c | 95 +++++++++++++++++++++++++++++++++++++++++ cmd-set-option.c | 6 ++- cmd-show-environment.c | 8 ++-- cmd-show-hooks.c | 62 +++++++++++++++++++++++++++ cmd-show-messages.c | 12 +++--- cmd-show-options.c | 28 +++++++++---- cmd-source-file.c | 3 +- cmd-split-window.c | 13 ++++-- cmd-swap-pane.c | 9 ++-- cmd-swap-window.c | 27 ++++++++---- cmd-switch-client.c | 20 +++++++-- cmd-unbind-key.c | 3 +- cmd-wait-for.c | 3 +- cmd.c | 34 +++++++++++++++ hooks.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ session.c | 2 + tmux.c | 2 + tmux.h | 59 ++++++++++++++++++++++++++ 72 files changed, 989 insertions(+), 277 deletions(-) create mode 100644 cmd-set-hook.c create mode 100644 cmd-show-hooks.c create mode 100644 hooks.c -- 2.1.4 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users