target.escape_format
Rust
- Python Unavailable
- TypeScript Unavailable
- Rust
- Go Unavailable
- Java Unavailable
- .NET Unavailable
- C++ Unavailable
- Swift Unavailable
- Module
- target
- Package
- libtmux
- Source
- crates/libtmux/src/target.rs
-
Escape text so tmux uses it as written rather than expanding it.
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"));
0 declared, 0 inherited