# pane.Pane.format

- **Module:** pane.Pane
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/pane.rs#L838
- **Page:** https://libtmux.org/en/rs/latest/reference/pane-pane-format/

```
pane.Pane.format(self, template: &str) -> Result<TmuxText, Error>
```

Expand a tmux format string in this pane's context.

This returns `display-message` output instead of showing it in front of
a person with [`Self::display`]. See [`crate::Server::format`] for the
shell boundary around command and recursive formats, and for why a `%`
in the template is a time conversion rather than literal text.

# Errors

Returns an error when tmux cannot be reached or refuses the format.

## Example

```rust
let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("shown").await?;
let window = session.active_window().await?.expect("a window");
let pane = window.active_pane().await?.expect("a pane");

let expanded = pane.format("#{pane_id}").await?;
assert_eq!(expanded.to_string_lossy(), pane.id().to_string());

guard.shutdown().await?;
```
