# Getting started

Source: https://libtmux.org/en/julia/latest/guides/getting-started/

> Getting started: LibTmux documentation.

LibTmux separates remote operations from captured data. Create an owned
daemon for a script, or explicitly select a borrowed endpoint. Remote
functions yield on I/O and work in ordinary Julia Tasks.

This manual follows `v0.1.0-alpha.1`, an unregistered source release. Start
with [Install](https://libtmux.org/en/julia/latest/guides/installation/), then return here for an owned-server program.
Product compatibility and the MCP/workspace applications remain under
verification; see [Compatibility](https://libtmux.org/en/julia/latest/guides/compatibility/).

The following source is the executable [`examples/owned_capture.jl`](<https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/examples/owned_capture.jl>) program.
It creates a session, captures the initial screen and asserts daemon cleanup.

```julia title="owned_capture.jl"
using LibTmux

function main()
    endpoint = Ref{Server}()
    result = with_server(; tmux=get(ENV, "LIBTMUX_TEST_TMUX", "tmux")) do server
        endpoint[] = server
        new_session(server; name="example", command=["/bin/cat"])
        snap = snapshot(server)
        pane = only(panes(snap))
        screen = capture_pane(server, pane.ref)
        @assert isempty(strip(screen))
        @assert only(sessions(snap)).name == "example"
        println("Captured ", string(pane.id), ": ", ncodeunits(screen), " screen bytes")
        (; snap, screen)
    end
    @assert !ispath(dirname(endpoint[].socket_path))
    @assert length(panes(result.snap)) == 1
    result
end

main()
```

Use [`Server`](https://libtmux.org/en/julia/latest/reference/libtmux-server/) for a borrowed endpoint. Neither construction nor local
snapshot reads contact tmux. [`from_env`](https://libtmux.org/en/julia/latest/reference/libtmux-from_env/) is the explicit opt-in to
ambient server selection. [`with_server`](https://libtmux.org/en/julia/latest/reference/libtmux-with_server/) owns its daemon; ordinary
server values do not.

Next, read [Captured queries](https://libtmux.org/en/julia/latest/concepts/queries/) for filtering and shared windows,
or [Ownership and I/O](https://libtmux.org/en/julia/latest/topics/ownership/) for effects, cancellation and control.
