pub struct Session { /* private fields */ }Expand description
A tmux session handle with an owned snapshot.
Implementations§
Source§impl Session
impl Session
Sourcepub async fn from_environment() -> Result<Self>
pub async fn from_environment() -> Result<Self>
Resolves the session containing the pane named by TMUX_PANE.
Sourcepub const fn name(&self) -> Option<&SessionName>
pub const fn name(&self) -> Option<&SessionName>
Returns the name captured in the current snapshot.
Sourcepub const fn snapshot(&self) -> &SessionSnapshot
pub const fn snapshot(&self) -> &SessionSnapshot
Returns the owned snapshot.
Sourcepub async fn refresh(&mut self) -> Result<()>
pub async fn refresh(&mut self) -> Result<()>
Replaces this object’s state with a fresh snapshot.
Sourcepub async fn cmd(&self, command: Command) -> Result<CommandResult>
pub async fn cmd(&self, command: Command) -> Result<CommandResult>
Runs an arbitrary tmux command targeted at this session.
Sourcepub async fn windows_or_empty(&self) -> Vec<Window>
pub async fn windows_or_empty(&self) -> Vec<Window>
Lists windows, returning an empty collection on failure.
Sourcepub async fn panes_or_empty(&self) -> Vec<Pane>
pub async fn panes_or_empty(&self) -> Vec<Pane>
Lists panes, returning an empty collection on failure.
Sourcepub async fn active_pane(&self) -> Result<Pane>
pub async fn active_pane(&self) -> Result<Pane>
Returns the active pane in this session’s active window.
Sourcepub async fn active_window(&self) -> Result<Window>
pub async fn active_window(&self) -> Result<Window>
Returns the active window link.
Sourcepub async fn window(&self, id: WindowId) -> Result<Window>
pub async fn window(&self, id: WindowId) -> Result<Window>
Resolves one window ID within this session.
Sourcepub async fn clients(&self) -> Result<Vec<Client>>
pub async fn clients(&self) -> Result<Vec<Client>>
Lists clients currently attached to this session.
Sourcepub async fn new_window(&self, options: NewWindow) -> Result<Window>
pub async fn new_window(&self, options: NewWindow) -> Result<Window>
Creates a window in this session.
Sourcepub async fn with_window<F, Fut, T>(
&self,
options: NewWindow,
operation: F,
) -> Result<T>
pub async fn with_window<F, Fut, T>( &self, options: NewWindow, operation: F, ) -> Result<T>
Creates a temporary window, runs an async operation, and attempts cleanup.
Sourcepub async fn rename(&mut self, name: impl Into<String>) -> Result<()>
pub async fn rename(&mut self, name: impl Into<String>) -> Result<()>
Renames the session and refreshes the snapshot.
Sourcepub async fn kill_window(&self, target: impl Into<WindowTarget>) -> Result<()>
pub async fn kill_window(&self, target: impl Into<WindowTarget>) -> Result<()>
Kills one selected window in this session.
Sourcepub async fn select_window(&self, window: impl Into<WindowTarget>) -> Result<()>
pub async fn select_window(&self, window: impl Into<WindowTarget>) -> Result<()>
Selects a window link in this session.
Sourcepub async fn next_window(&self, alert: bool) -> Result<()>
pub async fn next_window(&self, alert: bool) -> Result<()>
Selects the next window.
Sourcepub async fn previous_window(&self, alert: bool) -> Result<()>
pub async fn previous_window(&self, alert: bool) -> Result<()>
Selects the previous window.
Sourcepub async fn last_window(&self) -> Result<()>
pub async fn last_window(&self) -> Result<()>
Selects the last active window.
Sourcepub async fn renumber_windows(&self) -> Result<()>
pub async fn renumber_windows(&self) -> Result<()>
Renumbers this session’s window links.
Sourcepub async fn detach_clients(&self) -> Result<()>
pub async fn detach_clients(&self) -> Result<()>
Detaches every client attached to this session.
Sourcepub async fn detach_clients_with_command(
&self,
shell_command: OsString,
) -> Result<()>
pub async fn detach_clients_with_command( &self, shell_command: OsString, ) -> Result<()>
Detaches all clients and runs a shell command for each detached client.
Sourcepub async fn kill_with(
&self,
all_except: bool,
clear_alerts: bool,
group: bool,
) -> Result<()>
pub async fn kill_with( &self, all_except: bool, clear_alerts: bool, group: bool, ) -> Result<()>
Applies extended kill-session flags.
Sourcepub fn attach(&self, read_only: bool) -> Result<AttachedClient>
pub fn attach(&self, read_only: bool) -> Result<AttachedClient>
Starts an interactive attachment.
Sourcepub async fn kill(&self) -> Result<()>
pub async fn kill(&self) -> Result<()>
Destroys the session. Dropping the handle does not call this method.
Sourcepub async fn sparse_options(&self) -> Result<SparseOptionMap>
pub async fn sparse_options(&self) -> Result<SparseOptionMap>
Shows sparse options and hooks at session scope.
Sourcepub async fn set_option(
&self,
name: &str,
value: &OptionValue,
append: bool,
) -> Result<()>
pub async fn set_option( &self, name: &str, value: &OptionValue, append: bool, ) -> Result<()>
Sets a session option.
Sourcepub async fn unset_option(&self, name: &str) -> Result<()>
pub async fn unset_option(&self, name: &str) -> Result<()>
Unsets a session option.
Sourcepub async fn environment(&self) -> Result<BTreeMap<String, Option<TmuxText>>>
pub async fn environment(&self) -> Result<BTreeMap<String, Option<TmuxText>>>
Shows this session’s environment. Removed entries have a None value.
Sourcepub async fn environment_entry(
&self,
name: &str,
) -> Result<Option<Option<TmuxText>>>
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.
Sourcepub async fn set_environment(
&self,
name: &str,
value: impl Into<OsString>,
) -> Result<()>
pub async fn set_environment( &self, name: &str, value: impl Into<OsString>, ) -> Result<()>
Sets a session environment variable.
Sourcepub async fn set_environment_with(
&self,
name: &str,
value: impl Into<OsString>,
expand_formats: bool,
hidden: bool,
) -> Result<()>
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.
Sourcepub async fn unset_environment(&self, name: &str) -> Result<()>
pub async fn unset_environment(&self, name: &str) -> Result<()>
Unsets a session environment variable.
Sourcepub async fn remove_environment(&self, name: &str) -> Result<()>
pub async fn remove_environment(&self, name: &str) -> Result<()>
Marks a session environment variable as removed for future child processes.
Sourcepub async fn window_ids(&self) -> Result<BTreeSet<WindowId>>
pub async fn window_ids(&self) -> Result<BTreeSet<WindowId>>
Returns all distinct window IDs linked into this session.