Skip to content

Support on_project_first_start lifecycle hook (tmuxinator parity) #1028

@tony

Description

@tony

Feature Request

tmuxinator supports on_project_first_start — a lifecycle hook that fires only on first session creation, not on subsequent starts when the session already exists.

tmuxinator reference

From ~/study/ruby/tmuxinator/lib/tmuxinator/hooks/project.rb:17-20 and template.erb:16-22:

<%- if append? || !tmux_has_session?(name) -%>
  # First start path — on_project_first_start fires here
  <%= hook_on_project_first_start %>
  # ... create session ...
<%- else -%>
  # Restart path — on_project_restart fires here
<% end %>

The hook fires when !tmux_has_session?(name) — i.e., only when the session doesn't already exist.

Use case

on_project_first_start: rake db:create && rake db:migrate
on_project_restart: rake db:migrate
on_project_start: echo "starting"
  • First tmuxinator start: runs db:create && db:migrate (first start) + echo starting (always)
  • Subsequent tmuxinator start: runs db:migrate (restart) + echo starting (always)

Current state

  • The tmuxinator importer now passes on_project_first_start through with a warning (commit da089cc6)
  • The builder does not yet implement this hook
  • tmuxp has on_project_start (fires always) and on_project_restart (fires when session exists)

Implementation

In src/tmuxp/cli/load.py, the session-exists check at line 716 already distinguishes new vs existing sessions. The on_project_first_start hook should fire in the "new session" path (line 744) but NOT in the "session exists" path (line 716).

Files

  • src/tmuxp/cli/load.py — fire hook in new-session path only
  • src/tmuxp/workspace/loader.py — add to hook expansion list
  • src/tmuxp/workspace/importers.py — remove warning (already passes through)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions