Support on_project_first_start lifecycle hook (tmuxinator parity)

Open
#1,028 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
cli

Research direction

Start in src/tmuxp/cli/load.py at the session-exists check around lines 716 and 744, then inspect hook expansion in src/tmuxp/workspace/loader.py. Update src/tmuxp/workspace/importers.py where the pass-through warning is handled. Done means the hook runs only for a new session, not an existing one, while the other lifecycle hooks retain their behavior.

Written by the indexing model from the issue text.

Description

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)
Dominant language
Python
Stars
4.6k
Forks
248
Avg merge
2h 13m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tmux-python/tmuxp

All issues in tmux-python/tmuxp

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.