Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

target.escape_format

Rust
  • Python Unavailable
  • TypeScript Unavailable
  • Rust
  • Go Unavailable
  • Java Unavailable
  • .NET Unavailable
  • C++ Unavailable
  • Swift Unavailable

View as Markdown

Module
target
Package
libtmux
Source
crates/libtmux/src/target.rs
escape_format ( text : impl AsRef<OsStr> ) → OsString
function [source]
function [source]
escape_format

Escape text so tmux uses it as written rather than expanding it.

tmux runs its format machinery over more than names: #(command) runs command in a shell and #{session_id} becomes the id, in a session or window name and in the start directory -c names 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 raw crate::Command of 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

Esc

Type to search.