Skip to content

feat(shell): add startup_command run in each new pane#83

Open
roramirez wants to merge 1 commit into
mainfrom
feat/config-startup-command
Open

feat(shell): add startup_command run in each new pane#83
roramirez wants to merge 1 commit into
mainfrom
feat/config-startup-command

Conversation

@roramirez

Copy link
Copy Markdown
Owner

Summary

Adds a shell.startup_command config option. When set, the command is written to every newly spawned interactive pane (new tab or split) right after the shell starts — useful for e.g. ssh myserver. The command is intentionally not re-run for panes reconstructed from a saved session on restore.

Changes

  • src/config/mod.rs: add startup_command: Option<String> to ShellConfig (#[serde(default)], defaults to None).
  • src/pane_ops.rs: spawn_pane_into gains a run_startup: bool parameter. Interactive callers (spawn_pane, new_tab) pass true; restore callers in src/restore.rs pass false. When true and the config value is Some(non-empty), the command + \n is written to the new pane's PTY.
  • src/config/tui_config.rs: add F_STARTUP_COMMAND field (Startup Command) to the in-app config editor, with empty→None mapping in build_config.
  • assets/config.toml, README.md, doc/SPEC.md: document the option (commented example + spec table row and prose).
  • CHANGELOG.md: add entry under ## [Unreleased]### Added.
  • Tests: config round-trip (config_test.rs), empty→None / non-empty→Some decision through the config editor (tui_config_test.rs), and updated field-count / index-contiguity / navigation-clamp asserts.

Note on coverage: the empty→None/Some decision and config serialization round-trip are unit-tested. The end-to-end PTY-write path in spawn_pane_into requires a fully constructed App (window + renderer) and is not unit-tested; the write itself uses the existing, already-tested PtySession::write_input.

How to test

  1. Set in ~/.config/mmterm/config.toml:
    [shell]
    startup_command = "echo hello-from-startup"
  2. Launch mmterm — the initial pane runs the command. Open a new tab (or split) and confirm each new pane also runs it.
  3. Enable restore_session, save a session with Ctrl+Q, relaunch — restored panes do not re-run the command.
  4. cargo test — config round-trip and decision tests pass; cargo clippy --locked -- -D warnings is clean.

Write a configurable command to every newly spawned interactive pane
(new tab / split) right after the shell starts. Restored session panes
pass run_startup=false so the command is not re-run on restore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant