# LibTmux.save_buffer

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** Julia
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/src/pane_io.jl#L191
- **Page:** https://libtmux.org/en/julia/latest/reference/libtmux-save_buffer/

```
save_buffer(
    connection::LibTmux.ControlConnection,
    buffer::LibTmux.BufferRef;
    max_bytes,
    kwargs...
)

save_buffer(server::LibTmux.Server, buffer::LibTmux.BufferRef; max_bytes, kwargs...)
```

## Methods

### `save_buffer` (overload 1)

```julia
save_buffer(
    connection::LibTmux.ControlConnection,
    buffer::LibTmux.BufferRef;
    max_bytes,
    kwargs...
)
```

[Source](https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/src/control_buffers.jl#L85).

Read exact buffer bytes through a private local file and a completion fence. Names must be valid UTF-8 without control bytes, because tmux can reflect them in diagnostics or notifications. Missing buffers raise `StaleReference`. The observed size is checked before saving and before reading; concurrent replacement is not locked. `max_bytes` bounds returned bytes, not a concurrent daemon write to the spool. Local files are always removed; the buffer remains caller-owned. There is no subprocess fallback.

```julia
save_buffer(connection::ControlConnection, buffer::BufferRef; max_bytes=8388608, kwargs...)
```

### `save_buffer(server::LibTmux.Server, buffer::LibTmux.BufferRef; max_bytes, kwargs...)`

[Source](https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/src/pane_io.jl#L192).

Read exact buffer bytes without text conversion or newline changes.

## Parameters

- `connection` (`LibTmux.ControlConnection`) (for `save_buffer(connection, buffer, max_bytes, kwargs)`)
- `buffer` (`LibTmux.BufferRef`)
- `max_bytes` (`Int`)
  Default: `8 * 1024 ^ 2`.
- `kwargs`
- `server` (`LibTmux.Server`) (for `save_buffer(server, buffer, max_bytes, kwargs)`)
