Skip to content

v0.67.0 - Literal names and the Format opt-in

Choose a tag to compare

@tony tony released this 22 Nov 19:00
· 10 commits to master since this release

libtmux 0.67.0 keeps a # in session names, window names, pane titles, start directories and buffer paths as typed, where tmux used to expand it as a format, and adds Format to have tmux expand one value on purpose. Server.new_session() with kill_session=True kills only the exactly named session, and exact=True matches a session name exactly in kill_session(), switch_client() and attach_session().

Highlights

  • # is literal in names, titles, start directories and buffer paths. rename_window("build#2") names the window build#2, and rename_window("#S") names it #S rather than the session's name. This covers new_session, new_window, rename_session, rename_window, set_title, split, new_pane, the respawn methods, display_popup's start directory and title, display_menu's title, the paths of save_buffer and load_buffer, and run_shell's cwd on tmux 3.8, the first release that expands it (#901, #910).
  • Format opts one value into tmux's formats. pane.split(start_directory=Format("#{pane_current_path}")) opens a pane in the active pane's directory again. Each argument decides for itself, so one call can keep its name literal while expanding its start directory. +, join and Format.escape() add text from users or files and keep it literal, and adding plain text where tmux would read it as format syntax raises ValueError. Parameters that accept a format are typed str | Format, so a type checker flags a Format where tmux would store it as typed (#910).
  • new_session(kill_session=True) kills only the exactly named session. Creating doom with kill_session=True no longer removes doomsday (#899).
  • exact= for session names. kill_session, switch_client and attach_session accept exact=True to match a name exactly; without it they still match by prefix or pattern as tmux does, and warn when the name matched only that way (#899).

To keep tmux's expansion where you relied on it:

from libtmux import Format

pane.split(start_directory=Format("#{pane_current_path}"))
window.rename_window(Format("#{pane_current_command}"))

See Literal text and tmux formats for which arguments are literal and how to opt in, and the changelog for the full list.

What's Changed

  • Server(feat[kill_session]): Add exact= to match session names exactly by @tony in #899
  • tmux(fix[formats]): Keep # literal in names, titles and directories by @tony in #901
  • formats(feat[Format]): Opt into tmux formats by @tony in #910

Full Changelog: v0.66.0...v0.67.0