escape_format
Escape text so tmux uses it as written rather than expanding it.
Source and package
- Qualified name
-
libtmux::target:: escape _format - Module
- target
- Package
- libtmux
- Source
- crates/libtmux/src/target.rs
-
Description#
tmux runs its format machinery over more than names:
#(command)runscommandin a shell and#{session_id}becomes the id, in a session or window name and in the start directory-cnames alike. Doubling#is what tmux's parser reads as one literal#, so the text arrives as itself -- which also makes a directory whose name really contains#reachable, where passing it through unescaped does not.Every typed argument that tmux expands takes
TmuxArg, which applies this on conversion, so a caller reaches for this directly only when building a rawcrate::Commandof their own.Examples#
use std::ffi::OsString;use libtmux::escape_format;// Text that would otherwise run a command.assert_eq!(escape_format("#(id)"), OsString::from("##(id)"));// Ordinary text is unchanged.assert_eq!(escape_format("editor"), OsString::from("editor"));