Client.attached_session
The session this client is attached to.
Source and package
-
Description#
Nonewhen the client is attached to nothing, which is an ordinary state rather than a failure.Resolved through
#{session_id}rather than#{client_session}. The latter is what tmux calls the attachment, but it is a name, and a name is not a handle: tmux will create a session calleda:band then refuse to address it, because:separates a session from a window in a target. The ID is unambiguous by construction.Costs one tmux command. tmux fills a client's session into the same format tree it fills the client's own fields into, so the whole session snapshot comes back with the id rather than needing a listing after it.
Errors
Returns an error when tmux cannot be reached, or answers with an ID this crate cannot parse.
Examples#
Terminal window $ cargo test --package libtmux --all-features --test command_budget \asking_a_clientlet guard = libtmux::test::TestServer::new().await?;let server = guard.server();let session = server.new_session("work").await?;// A control-mode connection is a client, so the server has one to find.let control = libtmux::control::ControlMode::attach(server, session.id()).await?;let client = server.clients().await?.into_iter().next().expect("one client");let attached = client.attached_session().await?.expect("it is attached");assert_eq!(attached.id(), session.id());control.shutdown().await?;guard.shutdown().await?;
In other ports#
The session a client is attached to
| Language | Equivalent |
|---|---|
| Python | client_session is a session name, not a Session object |
| Ruby | Lib |
| Lua | libtmux |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | client |
| Go | tmux |
| Java | io |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| C++ | libtmux:: |
| Swift | the relationship is resolved through Snapshot.session(of:) |
| OCaml | Libtmux Returns the captured session when the attached client had one. |
| Perl | Lib Captured nullable relation; unloaded data remains an error. |
No equivalent is recorded in PowerShell, Julia, Erlang, Elixir, Common Lisp, Clojure or F#.