Skip to content

Phase 2: open command + naming + outside-tmux attach #2

Description

@dunnbot

Summary

Implement the no-args entry path: `mux` in a project dir creates or attaches a session. Outside-tmux only in this phase (inside-tmux behavior comes with restore in Phase 3).

Depends on #1.

Approach

  • `naming.rs` — port `~/.files/bin/mux:535-559`:
    • strip `$HOME/` and leading `.` from PWD
    • single segment → use as-is; multi-segment → `parent-base`
    • lowercase; replace `.` and `:` with `-`
  • `tmux/mod.rs` — `Tmux` trait. Real impl wraps `std::process::Command`. Fake impl for tests.
  • `commands/open.rs` — `mux` (no args) + `mux `:
    • register entry in TOML if absent
    • if session exists: attach / switch (no layout work yet — that's Phase 3)
    • if new: outside-tmux build chained `tmux new-session ; set-window-option automatic-rename off` invocation and `exec` it
  • No pane restore, no command capture in this phase — just attach/create.

Acceptance Criteria

  • `naming::tests` covers every case in the bash version (verify against PWDs in current `~/.files/tmux/sessions.json`)
  • `cd /tmp/scratch && mux` from outside tmux creates session `scratch` and attaches
  • `cd ~/Code/aniftyco/mux && mux` from outside tmux creates session `aniftyco-mux` and attaches
  • `mux myname` overrides the derived name
  • Re-running `mux` in the same dir attaches to the existing session

Files / Areas

  • `src/naming.rs`
  • `src/tmux/{mod,exec,fake}.rs`
  • `src/commands/open.rs`
  • `tests/naming.rs`, `tests/commands.rs` (open paths)

Notes

Inside-tmux behavior (tab-on-current, focus-primary-window) deferred to Phase 3 to keep this phase scoped to a single execution mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions