Title: `here` mode: `send_keys` for env vars and shell replacement diverges from teamocil and is unsafe · Issue #1030 · tmux-python/tmuxp · GitHub
Open Graph Title: `here` mode: `send_keys` for env vars and shell replacement diverges from teamocil and is unsafe · Issue #1030 · tmux-python/tmuxp
X Title: `here` mode: `send_keys` for env vars and shell replacement diverges from teamocil and is unsafe · Issue #1030 · tmux-python/tmuxp
Description: Problem --here mode in tmuxp uses send_keys to inject infrastructure commands (cd, export, shell replacement) into the active pane. This has three failure modes: export is not POSIX-universal — it's a syntax error in fish, nu, and other ...
Open Graph Description: Problem --here mode in tmuxp uses send_keys to inject infrastructure commands (cd, export, shell replacement) into the active pane. This has three failure modes: export is not POSIX-universal — it'...
X Description: Problem --here mode in tmuxp uses send_keys to inject infrastructure commands (cd, export, shell replacement) into the active pane. This has three failure modes: export is not POSIX-universal — it&...
Opengraph URL: https://github.com/tmux-python/tmuxp/issues/1030
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`here` mode: `send_keys` for env vars and shell replacement diverges from teamocil and is unsafe","articleBody":"## Problem\n\n`--here` mode in tmuxp uses `send_keys` to inject infrastructure commands (`cd`, `export`, shell replacement) into the active pane. This has three failure modes:\n\n1. **`export` is not POSIX-universal** — it's a syntax error in `fish`, `nu`, and other non-bash/zsh shells\n2. **Types into foreground programs** — if the active pane is running `vim`, `python`, `htop`, etc., the `cd`/`export` commands are typed as input, corrupting the user's session\n3. **Shell history pollution** — `cd` and `export` commands appear in the user's shell history\n\n### What tmuxp does (3 categories of `send_keys`)\n\n[`builder.py:695-727`](https://github.com/tmux-python/tmuxp/blob/886e63d37dbfeeefab1e645f168178b13ff03b7f/src/tmuxp/workspace/builder.py#L695-L727):\n\n```python\n# 1. Directory change via send_keys\nactive_pane.send_keys(f\"cd {shlex.quote(start_directory)}\", enter=True)\n\n# 2. Environment vars via send_keys (N calls, one per var)\n_here_pane.send_keys(f\"export {_ekey}={shlex.quote(str(_eval))}\", enter=True)\n\n# 3. Shell replacement via send_keys\n_here_pane.send_keys(window_shell, enter=True)\n```\n\n### What teamocil does (1 category of `send_keys`)\n\nteamocil's `--here` only uses `send_keys` for `cd` — the one unavoidable case. Everything else uses tmux primitives:\n\n- **Window rename**: [`rename-window`](https://github.com/remi/teamocil/blob/9ceecf5/lib/teamocil/tmux/window.rb#L67-L73) — tmux command, not `send_keys`\n- **Directory (`cd`)**: [`send_keys cd \"/path\"`](https://github.com/remi/teamocil/blob/9ceecf5/lib/teamocil/tmux/window.rb#L88-L95) — only `send_keys` usage\n- **Pane splitting**: [`split-window -c '/path'`](https://github.com/remi/teamocil/blob/9ceecf5/lib/teamocil/command/split_window.rb#L3-L13) — tmux primitive with `-c` for directory\n- **Environment vars**: Not handled at all — no `send_keys export`\n- **Shell replacement**: Not handled — teamocil doesn't change the running shell\n\ntmuxinator similarly never uses `send_keys` for infrastructure — only for user-specified pane commands. Directories use `-c` on [`new-window`](https://github.com/tmuxinator/tmuxinator/blob/4c836b8/lib/tmuxinator/window.rb#L120-L123) and [`splitw`](https://github.com/tmuxinator/tmuxinator/blob/4c836b8/lib/tmuxinator/pane.rb#L53-L58).\n\n### Impact\n\nCategories 2 and 3 (`export` and `window_shell`) are tmuxp-specific — neither Ruby tool does this. They are the primary source of the POSIX shell assumption and the \"types into vim\" failure mode.\n\n## Proposed solutions\n\nTwo approaches, tracked as sub-issues:\n\n- **Level 1** (#1031): Match teamocil — use `session.set_environment()` for env vars, `respawn-pane` for shell replacement, keep `send_keys cd` only\n- **Level 2** (#1032): Eliminate `send_keys` entirely — use `split-window`/`swap-pane`/`kill-pane` to create a fresh pane with correct dir+env\n\n## References\n\n- teamocil `--here` implementation: [`window.rb:67-95`](https://github.com/remi/teamocil/blob/9ceecf5/lib/teamocil/tmux/window.rb#L67-L95)\n- teamocil pane splitting with `-c`: [`split_window.rb`](https://github.com/remi/teamocil/blob/9ceecf5/lib/teamocil/command/split_window.rb#L3-L13)\n- teamocil `--here` tests: [`window_spec.rb:110-145`](https://github.com/remi/teamocil/blob/9ceecf5/spec/teamocil/tmux/window_spec.rb#L110-L145)\n- tmuxinator window creation (no `send_keys` for infra): [`window.rb:120-123`](https://github.com/tmuxinator/tmuxinator/blob/4c836b8/lib/tmuxinator/window.rb#L120-L123)\n- tmuxinator pane creation with `-c`: [`pane.rb:53-58`](https://github.com/tmuxinator/tmuxinator/blob/4c836b8/lib/tmuxinator/pane.rb#L53-L58)\n","author":{"url":"https://github.com/tony","@type":"Person","name":"tony"},"datePublished":"2026-03-29T09:32:18Z","url":"https://github.com/tmux-python/tmuxp/issues/1030"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:84690469-8894-6e5b-8b08-4c7daf013d8a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 811A:3D7740:2B39A2:3BF1D4:6B0088BC |
| html-safe-nonce | 2fe784934e8ca9407afa4894a1010dc8f9cca2fe29dff9d648d4d555d80237ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTFBOjNENzc0MDoyQjM5QTI6M0JGMUQ0OjZCMDA4OEJDIiwidmlzaXRvcl9pZCI6IjE2MDA2MDI3NjY3NTYwNTUyMjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 18539018f091b3ed049d1a0434a1f390e72fc9bedc9d30d1e5ef1f526418d3fa |
| hovercard-subject-tag | issue:4163549182 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/tmux-python/tmuxp/1030/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ebcfef0208b9f5535081901c6f3068821297bd0f735072c581454a5b57d6360a/tmux-python/tmuxp/issues/1030 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ebcfef0208b9f5535081901c6f3068821297bd0f735072c581454a5b57d6360a/tmux-python/tmuxp/issues/1030 |
| og:image:alt | Problem --here mode in tmuxp uses send_keys to inject infrastructure commands (cd, export, shell replacement) into the active pane. This has three failure modes: export is not POSIX-universal — it'... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tony |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4d3d8e50f02c1d7bf86d5acfa1d3bfe9366abd6528a6b429eb07a168429d2b61 |
| turbo-cache-control | no-preview |
| go-import | github.com/tmux-python/tmuxp git https://github.com/tmux-python/tmuxp.git |
| octolytics-dimension-user_id | 37234308 |
| octolytics-dimension-user_login | tmux-python |
| octolytics-dimension-repository_id | 12398170 |
| octolytics-dimension-repository_nwo | tmux-python/tmuxp |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 12398170 |
| octolytics-dimension-repository_network_root_nwo | tmux-python/tmuxp |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | db758f8e02b8257935fb03edf81a3e76eb3abd11 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width