Hi, Here's two rough patches outlining hook support. As discussed before (although never finalised, which I hope to do this time), I've implemented two new commands:
set-hook show-hooks I think the naming might be a little inconsistent. Hooks have a before/after concept with the long-name of the command prefered to active the hooks. Commands in hooks can be chained in the usual way, using ';', as in: set-hook -g -n 'after-new-session' 'run -b "notify-send new-session \ #{session_name}" ; run "notify-send hello"' Please give this as much testing as you can, and please pull it apart and let me know if this is just never going to work of if it's the best thing since sliced bread. I'm fairly happy with the approach of using prepare() to define the context of the running command for hooks. Note that I have not done anything about ancillary things like bell alerts yet, although that distinction is academic at this point if we're happy with the overall approach hook support has taken. Any questions do let me know. As I say I've only tested this lightly, and I expect things like segfaults, etc., where I might have fat-fingered something or otherwise done my usual party-trick of dereferencing NULL. You have been warned. :P Kindly, -- Thomas Adam Thomas Adam (2): Define hooks infrasructure Convert commands to support hooks Makefile.am | 3 ++ cmd-attach-session.c | 15 ++++++- cmd-bind-key.c | 10 ++++- cmd-break-pane.c | 18 +++++++- cmd-capture-pane.c | 16 ++++++- cmd-choose-buffer.c | 18 ++++++-- cmd-choose-client.c | 18 ++++++-- cmd-choose-list.c | 18 ++++++-- cmd-choose-tree.c | 27 +++++++++--- cmd-clear-history.c | 18 ++++++-- cmd-clock-mode.c | 18 ++++++-- cmd-command-prompt.c | 15 ++++++- cmd-confirm-before.c | 15 ++++++- cmd-copy-mode.c | 16 +++++-- cmd-delete-buffer.c | 10 ++++- cmd-detach-client.c | 24 +++++++--- cmd-display-message.c | 41 ++++++++++++----- cmd-display-panes.c | 18 ++++++-- cmd-find-window.c | 18 ++++++-- cmd-has-session.c | 18 +++++--- cmd-if-shell.c | 35 ++++++++++----- cmd-join-pane.c | 28 +++++++++--- cmd-kill-pane.c | 18 ++++++-- cmd-kill-server.c | 10 ++++- cmd-kill-session.c | 15 ++++++- cmd-kill-window.c | 18 +++++++- cmd-link-window.c | 24 ++++++++-- cmd-list-buffers.c | 10 ++++- cmd-list-clients.c | 22 +++++++--- cmd-list-commands.c | 10 ++++- cmd-list-keys.c | 10 ++++- cmd-list-panes.c | 24 ++++++++-- cmd-list-sessions.c | 10 ++++- cmd-list-windows.c | 18 ++++++-- cmd-load-buffer.c | 10 ++++- cmd-lock-server.c | 27 ++++++++---- cmd-move-window.c | 25 +++++++++-- cmd-new-session.c | 10 ++++- cmd-new-window.c | 25 +++++++++-- cmd-paste-buffer.c | 19 ++++++-- cmd-pipe-pane.c | 17 +++++++- cmd-queue.c | 46 ++++++++++++++++++- cmd-refresh-client.c | 15 ++++++- cmd-rename-session.c | 15 ++++++- cmd-rename-window.c | 17 ++++++-- cmd-resize-pane.c | 17 +++++++- cmd-respawn-pane.c | 18 +++++++- cmd-respawn-window.c | 17 +++++++- cmd-rotate-window.c | 16 +++++-- cmd-run-shell.c | 19 +++++++- cmd-save-buffer.c | 13 +++++- cmd-select-layout.c | 21 +++++++-- cmd-select-pane.c | 27 +++++++++--- cmd-select-window.c | 32 ++++++++++---- cmd-send-keys.c | 21 +++++++-- cmd-server-info.c | 10 ++++- cmd-set-buffer.c | 10 ++++- cmd-set-environment.c | 15 ++++++- cmd-set-hook.c | 101 ++++++++++++++++++++++++++++++++++++++++++ cmd-set-option.c | 6 ++- cmd-show-environment.c | 15 ++++++- cmd-show-hooks.c | 72 ++++++++++++++++++++++++++++++ cmd-show-messages.c | 18 ++++++-- cmd-show-options.c | 27 +++++++++--- cmd-source-file.c | 10 ++++- cmd-split-window.c | 18 +++++++- cmd-start-server.c | 10 ++++- cmd-suspend-client.c | 18 ++++++-- cmd-swap-pane.c | 18 ++++++-- cmd-swap-window.c | 26 ++++++++--- cmd-switch-client.c | 21 ++++++--- cmd-unbind-key.c | 10 ++++- cmd-unlink-window.c | 18 ++++++-- cmd-wait-for.c | 10 ++++- cmd.c | 17 ++++++++ hooks.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ session.c | 2 + tmux.c | 2 + tmux.h | 72 ++++++++++++++++++++++-------- 79 files changed, 1432 insertions(+), 241 deletions(-) create mode 100644 cmd-set-hook.c create mode 100644 cmd-show-hooks.c create mode 100644 hooks.c -- 1.7.10.4 ------------------------------------------------------------------------------ Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users