# session.Session.format

- **Module:** session.Session
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/session.rs#L645
- **Page:** https://libtmux.org/reference/rs/session-session-format/

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

Expand a tmux format string in this session'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.

# 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 expanded = session.format("#{session_name}").await?;
assert_eq!(expanded.to_string_lossy(), "shown");

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