Skip to content

fix: run :! and :term shell commands in the active pane's directory - #23

Merged
lordgreg merged 2 commits into
masterfrom
fix/20-active-pane-shell-cwd
Sep 9, 2026
Merged

fix: run :! and :term shell commands in the active pane's directory#23
lordgreg merged 2 commits into
masterfrom
fix/20-active-pane-shell-cwd

Conversation

@lordgreg

@lordgreg lordgreg commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #20.

Both :!cmd (run_shell_capture in src/ui/input.rs) and :term cmd (run_pending_shell_command in src/ui/mod.rs) spawned sh -c without setting a working directory, so the child process inherited rodeo's own process cwd instead of the currently active pane's directory. This is broader than "always the left pane" — it's "always wherever rodeo was launched from" — which just happens to usually match the left pane's initial directory, matching the reported symptom.

Changes

  • src/ui/input.rs: run_shell_capture now captures the active pane's path up front and passes it via .current_dir() to the spawned shell.

  • src/ui/mod.rs: run_pending_shell_command gets the identical fix for :term.

  • src/ui/input.rs: added 3 regression tests:

    • shell_capture_runs_in_the_right_panes_directory_when_right_is_active
    • shell_capture_runs_in_the_left_panes_directory_by_default
    • shell_capture_follows_active_pane_switches_mid_session

    Each redirects pwd's stdout to a marker file (!pwd > '<path>') rather than relying on the in-app output-capture UI, and canonicalizes the tempdir paths before comparison to avoid flakiness from symlinked temp dirs (e.g. macOS /var/private/var), matching the existing convention already used in src/ui/git.rs.

  • CHANGELOG.md: new # Unreleased / ## Fixed entry.

Scope notes

  • Audited other Command::new spawn sites for the same gap: src/ui/git.rs already passes -C <dir> explicitly, and src/updater.rs's calls aren't pane-relative — no changes needed there.
  • The $EDITOR launch (src/ui/mod.rs, run_pending_editor) has the same theoretical missing-.current_dir() gap, but it opens an absolute file path and isn't part of this issue's report, so it's deliberately left untouched — worth a separate follow-up if desired.
  • run_pending_shell_command (:term) isn't covered by a direct automated test, since it requires a live terminal and blocks on stdin; the fix is a one-line change identical in shape to the tested :! path.

Verification

  • cargo build — clean, no warnings
  • cargo test — 525 tests, all passing (506 unit + 7 file_ops + 1 man + 11 render)
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --check — clean

Both `run_shell_capture` (:!) and `run_pending_shell_command` (:term) spawned
`sh -c` without setting a working directory, so they inherited rodeo's own
process cwd instead of the currently active pane's directory. Add
`.current_dir()` to both call sites, plus regression tests covering the
right-pane-active, left-pane-active, and mid-session-switch cases.

Fixes #20
@lordgreg
lordgreg merged commit 9ecaee0 into master Sep 9, 2026
4 checks passed
@lordgreg
lordgreg deleted the fix/20-active-pane-shell-cwd branch September 9, 2026 18:34
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.

:pwd Command shows the left pane's directory.

1 participant