Add New Window to the pane context menu - #23
Merged
Conversation
netj
requested changes
Aug 18, 2026
PR netj#23 review asked for a static compile instead of a python script that parses and patches the live tmux binding at runtime (3-way python-tmux-sh coupling). optmux/menu.py now keeps a literal copy of tmux's own session/window/pane menu items and lets optmux.yaml's `menu:` section redeclare each menu in full -- reordering, retitling, or remapping default items by name, adding custom ones, with a bare "*" to pull in the rest of tmux's defaults unchanged. This compiles to a static tmux.optmux-menu.conf of bind/display-menu lines, replacing pane_menu.py's runtime list-keys/ source-file dance. optmux-defaults.yaml now ships the "New Window" pane item through this mechanism. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Extract the shortcuts command-building logic (command/tmux/send_keys/
new_window/float_window/zoom/detached/remain) into optmux/actions.py,
shared by generate_shortcut_line (cli.py) and menu custom items
(menu.py). Custom menu items now support the full shortcuts vocabulary
instead of a stripped-down command/new_window-only subset.
- Replace \" escapes in the DEFAULT_MENUS tmux-syntax literals with
triple-quoted strings.
- Replace f-string {{ }} brace-doubling in menu.py's bind-line builders
and item compiler with %-formatting, since tmux's own syntax is brace-
heavy and doubling every literal brace hurt readability.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…mples - menu.py's implicit new_window default for custom items now only kicks in when the item names neither new_window nor float_window -- an item with float_window: true alone no longer trips the "mutually exclusive" warning against a default it never asked for. Caught while validating new doc examples against the real compiler. - README: pull the shared command/tmux/send_keys/new_window/float_window/ zoom/detached/remain vocabulary out into a dedicated "Action block" section referenced by both Shortcuts and Menu, instead of duplicating it. Add a menu example gallery (floating lazygit, send_keys test runner, detached background copy, retitle/remap a default item, and full manual enumeration to replace a default item's behavior) -- every example is compiled and tmux-loaded as part of verifying this commit. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Shows a custom pane-menu item reusing an existing shortcut's command (Edit README) and a retitled/remapped default window-menu item (Kill -> Close Window / q), alongside the shortcuts: this file already demonstrates. Verified via the real CLI (uv run optmux ./example.optmux.yaml) that both compile into tmux.optmux-menu.conf and source cleanly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
tmux's choose-tree -Zw (normally only reachable via prefix w) opens an interactive window/pane tree picker. Added as a session-menu item in both the README's full-enumeration example and example.optmux.yaml, under key 'T' to avoid colliding with the default menu's own 'w' (New Window). Verified compiling with no warnings and sourcing into real tmux, and via the actual CLI for example.optmux.yaml. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Owner
|
check this out! I got a fully configurable menu to work via optmux.menu section in the yaml. Lines 24 to 39 in d6f5039
|
…u-new-window # Conflicts: # optmux/cli.py
Contributor
Author
LGTM lol Thank you!!! |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
New Window (C-t c)to the pane right-click menu with acceleratorwDesign
tmux does not expose an API for appending to its built-in pane menu. The managed helper reads the canonical
MouseDown3Panebinding, inserts the action only at a verified stable or floating-pane anchor, sources the candidate, and confirms the exact resulting binding. Existing and future custom menus remain untouched when the transformation cannot be proven safe.Verification
uv run pytest -q— 134 passedw, and verifies the new window inherits the inactive clicked pane cwdpython3 -m py_compile optmux/pane_menu.pyuv lock --checkuv build; wheel and sdist contain the helper and updated tmux configgit diff --check origin/mainThe build succeeds with the existing warning that local uv 0.12.3 is newer than the declared
uv_build <0.12.0range.