Skip to main content

Session

Struct Session 

Source
pub struct Session { /* private fields */ }
Expand description

A tmux session handle with an owned snapshot.

Implementations§

Source§

impl Session

Source

pub async fn from_environment() -> Result<Self>

Resolves the session containing the pane named by TMUX_PANE.

Source

pub const fn id(&self) -> SessionId

Returns the immutable tmux ID.

Source

pub const fn name(&self) -> Option<&SessionName>

Returns the name captured in the current snapshot.

Source

pub const fn snapshot(&self) -> &SessionSnapshot

Returns the owned snapshot.

Source

pub const fn server(&self) -> &Server

Returns the server handle used by this object.

Source

pub async fn refresh(&mut self) -> Result<()>

Replaces this object’s state with a fresh snapshot.

Source

pub async fn cmd(&self, command: Command) -> Result<CommandResult>

Runs an arbitrary tmux command targeted at this session.

Source

pub async fn windows(&self) -> Result<Vec<Window>>

Lists window links owned by this session.

Source

pub async fn windows_or_empty(&self) -> Vec<Window>

Lists windows, returning an empty collection on failure.

Source

pub async fn panes(&self) -> Result<Vec<Pane>>

Lists every pane belonging to this session.

Source

pub async fn panes_or_empty(&self) -> Vec<Pane>

Lists panes, returning an empty collection on failure.

Source

pub async fn active_pane(&self) -> Result<Pane>

Returns the active pane in this session’s active window.

Source

pub async fn active_window(&self) -> Result<Window>

Returns the active window link.

Source

pub async fn window(&self, id: WindowId) -> Result<Window>

Resolves one window ID within this session.

Source

pub async fn clients(&self) -> Result<Vec<Client>>

Lists clients currently attached to this session.

Source

pub async fn new_window(&self, options: NewWindow) -> Result<Window>

Creates a window in this session.

Source

pub async fn with_window<F, Fut, T>( &self, options: NewWindow, operation: F, ) -> Result<T>
where F: FnOnce(Window) -> Fut, Fut: Future<Output = Result<T>>,

Creates a temporary window, runs an async operation, and attempts cleanup.

Source

pub async fn rename(&mut self, name: impl Into<String>) -> Result<()>

Renames the session and refreshes the snapshot.

Source

pub async fn select(&self) -> Result<()>

Selects this session for the invoking client.

Source

pub async fn lock(&self) -> Result<()>

Locks clients attached to this session.

Source

pub async fn kill_window(&self, target: impl Into<WindowTarget>) -> Result<()>

Kills one selected window in this session.

Source

pub async fn select_window(&self, window: impl Into<WindowTarget>) -> Result<()>

Selects a window link in this session.

Source

pub async fn next_window(&self, alert: bool) -> Result<()>

Selects the next window.

Source

pub async fn previous_window(&self, alert: bool) -> Result<()>

Selects the previous window.

Source

pub async fn last_window(&self) -> Result<()>

Selects the last active window.

Source

pub async fn renumber_windows(&self) -> Result<()>

Renumbers this session’s window links.

Source

pub async fn detach_clients(&self) -> Result<()>

Detaches every client attached to this session.

Source

pub async fn detach_clients_with_command( &self, shell_command: OsString, ) -> Result<()>

Detaches all clients and runs a shell command for each detached client.

Source

pub async fn kill_with( &self, all_except: bool, clear_alerts: bool, group: bool, ) -> Result<()>

Applies extended kill-session flags.

Source

pub fn attach(&self, read_only: bool) -> Result<AttachedClient>

Starts an interactive attachment.

Source

pub async fn kill(&self) -> Result<()>

Destroys the session. Dropping the handle does not call this method.

Source

pub async fn options(&self) -> Result<OptionMap>

Shows options at session scope.

Source

pub async fn sparse_options(&self) -> Result<SparseOptionMap>

Shows sparse options and hooks at session scope.

Source

pub async fn set_option( &self, name: &str, value: &OptionValue, append: bool, ) -> Result<()>

Sets a session option.

Source

pub async fn unset_option(&self, name: &str) -> Result<()>

Unsets a session option.

Source

pub async fn environment(&self) -> Result<BTreeMap<String, Option<TmuxText>>>

Shows this session’s environment. Removed entries have a None value.

Source

pub async fn environment_entry( &self, name: &str, ) -> Result<Option<Option<TmuxText>>>

Returns one session environment entry.

The outer option distinguishes an unknown name; the inner option is None when tmux records the name as explicitly removed.

Source

pub async fn set_environment( &self, name: &str, value: impl Into<OsString>, ) -> Result<()>

Sets a session environment variable.

Source

pub async fn set_environment_with( &self, name: &str, value: impl Into<OsString>, expand_formats: bool, hidden: bool, ) -> Result<()>

Sets a session environment variable with format expansion or hidden storage.

Source

pub async fn unset_environment(&self, name: &str) -> Result<()>

Unsets a session environment variable.

Source

pub async fn remove_environment(&self, name: &str) -> Result<()>

Marks a session environment variable as removed for future child processes.

Source

pub async fn window_ids(&self) -> Result<BTreeSet<WindowId>>

Returns all distinct window IDs linked into this session.

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Session

Source§

impl PartialEq for Session

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more