tmuxtmuxinator

How do you trigger custom commands or scripts when running the tmux stop command?


I want to be able to cleanly stop some associated services if I run tmux stop

For example, if there's a docker instance running, stop that. Basically I want to be able to trigger a custom script / commands that will be executed on issues the tmux stop command.

Any ideas how this can be accomplished?

Read the manual - couldn't find it!

Thanks in advance.


Solution

  • You can use project hooks to achieve what you're after. They are mentioned in the README and there should be some lightly documented examples in your project's config file, if it was generated using tmuxinator new hook-demo.

    Here's a very basic example which you should be able to use as a starting point:

    # ~/.tmuxinator/hook-demo.yml
    
    name: hook-demo
    on_project_stop: echo "On `tmuxinator stop hook-demo`" && sleep 2
    on_project_exit: echo "On detach (prefix+d)" && sleep 2
    root: ~/
    windows:
      - one:
          panes:
            - echo hi
    

    These could definitely be called out better in the documentation and we'd be happy to consider any feedback you may have.