# tmux_query:fetch/2

- **Package:** libtmux_erlang
- **Language:** Erlang
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-erlang/blob/d1b6308440cf9eb8f6647e7ae434bce60e849368/apps/libtmux_erlang/src/tmux_query.erl#L231
- **Page:** https://libtmux.org/en/erlang/latest/reference/tmux_query-fetch-2/

```
fetch/2
-spec fetch(t(), fetch_options()) ->
               {ok, tmux_select:t()} | {error, map()}.
```

Execute the planned observation, full local predicate and final limit.

Capture options are those of `tmux_server:snapshot/2`. retry is 0 (default) or
1 and retries only inconsistent_capture, within the original capture deadline.
The retry is a new read-only capture. No mutations are retried. Invalid
capture requests return tagged errors, including unsupported consistency.

## Examples

```erlang
1> tmux_query:fetch(tmux_query:panes(unopened), #{retry => 2}).
{error,#{code => invalid_query_options}}
```

## Parameters

- `Query` (`t()`)
- `Options` (`fetch_options()`)

## tmux command

The tmux commands behind `fetch/2`.

- [`list-panes`](/en/tmux/latest/manual/list-panes/) `-a` server scope, [`cmd_list_panes_server`](/en/tmux/latest/reference/c-function-cmd-list-panes-c-cmd_list_panes_server/) (the server has a session) (source: `apps/libtmux_erlang/src/tmux_observe.erl:129`)
- [`list-sessions`](/en/tmux/latest/manual/list-sessions/)
- [`list-windows`](/en/tmux/latest/manual/list-windows/) `-a` server scope, [`cmd_list_windows_exec`](/en/tmux/latest/reference/c-function-cmd-list-windows-c-cmd_list_windows_exec/) (the server has a session) (source: `apps/libtmux_erlang/src/tmux_observe.erl:129`)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_list_panes_entry`](/en/tmux/latest/reference/c-variable-cmd_list_panes_entry/) (attribute)
- [`cmd_list_panes_server`](/en/tmux/latest/reference/c-function-cmd-list-panes-c-cmd_list_panes_server/) (function)
- [`cmd_list_sessions_entry`](/en/tmux/latest/reference/c-variable-cmd_list_sessions_entry/) (attribute)
- [`cmd_list_sessions_exec`](/en/tmux/latest/reference/c-function-cmd-list-sessions-c-cmd_list_sessions_exec/) (function)
- [`cmd_list_windows_entry`](/en/tmux/latest/reference/c-variable-cmd_list_windows_entry/) (attribute)
- [`cmd_list_windows_exec`](/en/tmux/latest/reference/c-function-cmd-list-windows-c-cmd_list_windows_exec/) (function)
