pub struct Server { /* private fields */ }Expand description
A cheap handle to one tmux server configuration.
Implementations§
Source§impl Server
impl Server
Sourcepub async fn run_shell(&self, options: RunShell) -> Result<Option<TmuxText>>
pub async fn run_shell(&self, options: RunShell) -> Result<Option<TmuxText>>
Runs a shell or tmux command job.
Sourcepub async fn wait_for(&self, channel: &str, action: WaitAction) -> Result<()>
pub async fn wait_for(&self, channel: &str, action: WaitAction) -> Result<()>
Waits, signals, locks, or unlocks a named channel.
Sourcepub async fn bind_key(&self, binding: KeyBinding) -> Result<()>
pub async fn bind_key(&self, binding: KeyBinding) -> Result<()>
Creates or replaces a key binding.
Sourcepub async fn unbind_key(&self, options: UnbindKey) -> Result<()>
pub async fn unbind_key(&self, options: UnbindKey) -> Result<()>
Removes one or more key bindings.
Sourcepub async fn list_keys(
&self,
table: Option<&str>,
format: Option<&str>,
) -> Result<Vec<TmuxText>>
pub async fn list_keys( &self, table: Option<&str>, format: Option<&str>, ) -> Result<Vec<TmuxText>>
Lists key bindings as byte-preserving lines.
Sourcepub async fn list_commands(&self, name: Option<&str>) -> Result<Vec<TmuxText>>
pub async fn list_commands(&self, name: Option<&str>) -> Result<Vec<TmuxText>>
Lists tmux commands, optionally narrowed by name.
Sourcepub async fn lock_server(&self) -> Result<()>
pub async fn lock_server(&self) -> Result<()>
Locks every attached client.
Sourcepub async fn server_access(
&self,
action: ServerAccess,
) -> Result<Option<Vec<TmuxText>>>
pub async fn server_access( &self, action: ServerAccess, ) -> Result<Option<Vec<TmuxText>>>
Applies or lists server ACL rules. Requires tmux 3.3+.
Sourcepub async fn confirm_before(&self, options: ConfirmBefore) -> Result<()>
pub async fn confirm_before(&self, options: ConfirmBefore) -> Result<()>
Opens a background confirmation prompt.
Sourcepub async fn command_prompt(&self, options: CommandPrompt) -> Result<()>
pub async fn command_prompt(&self, options: CommandPrompt) -> Result<()>
Opens a background command prompt.
Displays an attached-client menu.
Sourcepub async fn display(&self, options: DisplayMessage) -> Result<Option<TmuxText>>
pub async fn display(&self, options: DisplayMessage) -> Result<Option<TmuxText>>
Runs the broad server-scoped display-message operation.
Sourcepub async fn start_server(&self) -> Result<()>
pub async fn start_server(&self) -> Result<()>
Starts the tmux daemon without creating a session.
Sourcepub async fn show_messages(
&self,
client: Option<&ClientName>,
terminals: bool,
jobs: bool,
) -> Result<Vec<TmuxText>>
pub async fn show_messages( &self, client: Option<&ClientName>, terminals: bool, jobs: bool, ) -> Result<Vec<TmuxText>>
Shows server messages, terminal capabilities, or jobs.
Sourcepub async fn refresh_client(
&self,
client: Option<&ClientName>,
request_clipboard: bool,
) -> Result<()>
pub async fn refresh_client( &self, client: Option<&ClientName>, request_clipboard: bool, ) -> Result<()>
Refreshes a client display and optionally requests the clipboard.
Sourcepub async fn send_client_key(
&self,
client: &ClientName,
key: impl Into<OsString>,
) -> Result<()>
pub async fn send_client_key( &self, client: &ClientName, key: impl Into<OsString>, ) -> Result<()>
Sends one key to an attached client’s key handling state. Requires tmux 3.4+.
Sourcepub async fn suspend_client(&self, client: Option<&ClientName>) -> Result<()>
pub async fn suspend_client(&self, client: Option<&ClientName>) -> Result<()>
Suspends an explicit or current client.
Sourcepub async fn lock_client(&self, client: Option<&ClientName>) -> Result<()>
pub async fn lock_client(&self, client: Option<&ClientName>) -> Result<()>
Locks an explicit or current client.
Sourcepub async fn detach_client(
&self,
client: Option<&ClientName>,
shell_command: Option<OsString>,
) -> Result<()>
pub async fn detach_client( &self, client: Option<&ClientName>, shell_command: Option<OsString>, ) -> Result<()>
Detaches an explicit or current client, optionally running a shell command afterward.
Sourcepub async fn detach_all_clients(
&self,
keep: Option<&ClientName>,
shell_command: Option<OsString>,
) -> Result<()>
pub async fn detach_all_clients( &self, keep: Option<&ClientName>, shell_command: Option<OsString>, ) -> Result<()>
Detaches all clients except an optional retained client.
Sourcepub async fn if_shell(&self, options: IfShell) -> Result<()>
pub async fn if_shell(&self, options: IfShell) -> Result<()>
Executes one of two tmux commands based on a shell or format condition.
Sourcepub async fn prompt_history(
&self,
prompt_type: Option<PromptType>,
) -> Result<Vec<TmuxText>>
pub async fn prompt_history( &self, prompt_type: Option<PromptType>, ) -> Result<Vec<TmuxText>>
Shows prompt history. Requires tmux 3.3+.
Sourcepub async fn clear_prompt_history(
&self,
prompt_type: Option<PromptType>,
) -> Result<()>
pub async fn clear_prompt_history( &self, prompt_type: Option<PromptType>, ) -> Result<()>
Clears prompt history. Requires tmux 3.3+.
Sourcepub async fn run_hook(&self, name: &str, target: Option<&str>) -> Result<()>
pub async fn run_hook(&self, name: &str, target: Option<&str>) -> Result<()>
Runs a named hook immediately.
Sourcepub async fn set_hook(
&self,
scope: HookScope,
target: Option<&str>,
name: &str,
index: Option<u32>,
value: &OptionValue,
append: bool,
) -> Result<()>
pub async fn set_hook( &self, scope: HookScope, target: Option<&str>, name: &str, index: Option<u32>, value: &OptionValue, append: bool, ) -> Result<()>
Sets one hook command, optionally at a sparse index.
Sourcepub async fn unset_hook(
&self,
scope: HookScope,
target: Option<&str>,
name: &str,
index: Option<u32>,
) -> Result<()>
pub async fn unset_hook( &self, scope: HookScope, target: Option<&str>, name: &str, index: Option<u32>, ) -> Result<()>
Unsets one hook or sparse hook index.
Sourcepub async fn show_hooks(
&self,
scope: HookScope,
target: Option<&str>,
) -> Result<SparseOptionMap>
pub async fn show_hooks( &self, scope: HookScope, target: Option<&str>, ) -> Result<SparseOptionMap>
Shows hooks as sparse option arrays.
Source§impl Server
impl Server
Sourcepub async fn list_buffers(
&self,
format: Option<&str>,
filter: Option<&NativeFilter>,
) -> Result<Vec<TmuxText>>
pub async fn list_buffers( &self, format: Option<&str>, filter: Option<&NativeFilter>, ) -> Result<Vec<TmuxText>>
Lists buffers with a raw output format and optional native filter.
Sourcepub async fn buffers_or_empty(&self) -> Vec<Buffer>
pub async fn buffers_or_empty(&self) -> Vec<Buffer>
Lists buffers, returning an empty collection on failure.
Sourcepub async fn buffer(&self, name: &BufferName) -> Result<Buffer>
pub async fn buffer(&self, name: &BufferName) -> Result<Buffer>
Resolves an exact buffer name.
Sourcepub async fn load_buffer(
&self,
name: Option<&BufferName>,
data: impl Into<TmuxText>,
) -> Result<Buffer>
pub async fn load_buffer( &self, name: Option<&BufferName>, data: impl Into<TmuxText>, ) -> Result<Buffer>
Loads byte-preserving data through stdin and returns its resulting buffer.
Sourcepub async fn load_buffer_file(
&self,
name: Option<&BufferName>,
path: impl AsRef<Path>,
) -> Result<Buffer>
pub async fn load_buffer_file( &self, name: Option<&BufferName>, path: impl AsRef<Path>, ) -> Result<Buffer>
Loads a filesystem path into a named or automatic tmux buffer.
Sourcepub async fn set_buffer(
&self,
name: Option<&BufferName>,
data: impl Into<TmuxText>,
append: bool,
) -> Result<Buffer>
pub async fn set_buffer( &self, name: Option<&BufferName>, data: impl Into<TmuxText>, append: bool, ) -> Result<Buffer>
Sets text using set-buffer. Prefer Self::load_buffer for arbitrary bytes.
Sourcepub async fn show_buffer(&self, name: Option<&BufferName>) -> Result<TmuxText>
pub async fn show_buffer(&self, name: Option<&BufferName>) -> Result<TmuxText>
Reads a named buffer or tmux’s most recent buffer.
Sourcepub async fn delete_buffer(&self, name: Option<&BufferName>) -> Result<()>
pub async fn delete_buffer(&self, name: Option<&BufferName>) -> Result<()>
Deletes a named buffer or tmux’s most recent buffer.
Sourcepub async fn save_buffer(
&self,
name: &BufferName,
path: impl AsRef<Path>,
append: bool,
) -> Result<()>
pub async fn save_buffer( &self, name: &BufferName, path: impl AsRef<Path>, append: bool, ) -> Result<()>
Saves a buffer to a filesystem path through tmux.
Source§impl Server
impl Server
Sourcepub fn builder() -> ServerBuilder
pub fn builder() -> ServerBuilder
Starts configuring a server handle.
Sourcepub fn from_environment() -> Result<Self>
pub fn from_environment() -> Result<Self>
Creates a server for the socket recorded in the TMUX environment variable.
Sourcepub fn config(&self) -> &ServerConfig
pub fn config(&self) -> &ServerConfig
Returns shared immutable configuration.
Sourcepub async fn cmd(&self, command: Command) -> Result<CommandResult>
pub async fn cmd(&self, command: Command) -> Result<CommandResult>
Executes a command without treating a non-zero tmux exit status as an error.
Sourcepub async fn version(&self) -> Result<&TmuxVersion>
pub async fn version(&self) -> Result<&TmuxVersion>
Reads and caches the version reported by the configured executable.
Sourcepub async fn sessions(&self) -> Result<Vec<Session>>
pub async fn sessions(&self) -> Result<Vec<Session>>
Lists sessions, preserving an error when the server is unavailable.
Sourcepub async fn sessions_filtered(
&self,
filter: Option<&NativeFilter>,
) -> Result<Vec<Session>>
pub async fn sessions_filtered( &self, filter: Option<&NativeFilter>, ) -> Result<Vec<Session>>
Lists sessions with an optional native tmux filter.
Sourcepub async fn sessions_or_empty(&self) -> Vec<Session>
pub async fn sessions_or_empty(&self) -> Vec<Session>
Lists sessions, returning an empty collection on discovery failure.
Sourcepub async fn attached_sessions(&self) -> Result<Vec<Session>>
pub async fn attached_sessions(&self) -> Result<Vec<Session>>
Lists sessions with at least one attached client.
Sourcepub async fn session(&self, id: SessionId) -> Result<Session>
pub async fn session(&self, id: SessionId) -> Result<Session>
Resolves a session ID to a fresh snapshot.
Sourcepub async fn session_by_name(&self, name: &SessionName) -> Result<Session>
pub async fn session_by_name(&self, name: &SessionName) -> Result<Session>
Resolves an exact session name to a fresh snapshot.
Sourcepub async fn windows(&self) -> Result<Vec<Window>>
pub async fn windows(&self) -> Result<Vec<Window>>
Lists every window link. A window linked into two sessions appears twice.
Sourcepub async fn windows_filtered(
&self,
filter: Option<&NativeFilter>,
) -> Result<Vec<Window>>
pub async fn windows_filtered( &self, filter: Option<&NativeFilter>, ) -> Result<Vec<Window>>
Lists window links with an optional native tmux filter.
Sourcepub async fn windows_or_empty(&self) -> Vec<Window>
pub async fn windows_or_empty(&self) -> Vec<Window>
Lists window links, returning an empty collection on discovery failure.
Sourcepub async fn window(&self, id: WindowId) -> Result<Window>
pub async fn window(&self, id: WindowId) -> Result<Window>
Resolves a window ID. Fails loudly when the window has multiple links.
Sourcepub async fn panes_filtered(
&self,
filter: Option<&NativeFilter>,
) -> Result<Vec<Pane>>
pub async fn panes_filtered( &self, filter: Option<&NativeFilter>, ) -> Result<Vec<Pane>>
Lists panes with an optional native tmux filter.
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 discovery failure.
Sourcepub async fn clients_or_empty(&self) -> Vec<Client>
pub async fn clients_or_empty(&self) -> Vec<Client>
Lists clients, returning an empty collection on discovery failure.
Sourcepub async fn has_session(&self, name: &SessionName) -> Result<bool>
pub async fn has_session(&self, name: &SessionName) -> Result<bool>
Returns whether an exact session name exists.
Sourcepub async fn kill_session(&self, target: impl Into<SessionTarget>) -> Result<()>
pub async fn kill_session(&self, target: impl Into<SessionTarget>) -> Result<()>
Kills a selected session target.
Sourcepub async fn new_session(&self, options: NewSession) -> Result<Session>
pub async fn new_session(&self, options: NewSession) -> Result<Session>
Creates a session and hydrates its initial snapshot.
Sourcepub async fn with_session<F, Fut, T>(
&self,
options: NewSession,
operation: F,
) -> Result<T>
pub async fn with_session<F, Fut, T>( &self, options: NewSession, operation: F, ) -> Result<T>
Creates a temporary session, runs an async operation, and always attempts cleanup.
Sourcepub async fn kill(&self) -> Result<()>
pub async fn kill(&self) -> Result<()>
Kills the tmux server. A missing server is treated as already killed.
Sourcepub async fn is_alive(&self) -> Result<bool>
pub async fn is_alive(&self) -> Result<bool>
Returns whether the configured tmux server responds.
Sourcepub async fn ensure_alive(&self) -> Result<()>
pub async fn ensure_alive(&self) -> Result<()>
Returns a server-unavailable error unless tmux responds successfully.
Sourcepub async fn pane_from_environment(&self) -> Result<Pane>
pub async fn pane_from_environment(&self) -> Result<Pane>
Resolves TMUX_PANE using this server’s socket configuration.
Sourcepub async fn source_file(&self, path: impl AsRef<Path>) -> Result<()>
pub async fn source_file(&self, path: impl AsRef<Path>) -> Result<()>
Sources a tmux configuration file.
Sourcepub async fn source_file_with(
&self,
path: impl AsRef<Path>,
quiet: bool,
parse_only: bool,
verbose: bool,
) -> Result<()>
pub async fn source_file_with( &self, path: impl AsRef<Path>, quiet: bool, parse_only: bool, verbose: bool, ) -> Result<()>
Sources or validates a config file with explicit flags.
Sourcepub async fn display_message(
&self,
message: impl Into<OsString>,
) -> Result<TmuxText>
pub async fn display_message( &self, message: impl Into<OsString>, ) -> Result<TmuxText>
Displays a message and returns tmux’s byte-preserving expansion.
Sourcepub async fn show_options(
&self,
scope: OptionScope,
target: Option<&str>,
) -> Result<OptionMap>
pub async fn show_options( &self, scope: OptionScope, target: Option<&str>, ) -> Result<OptionMap>
Shows options at a scope and optional target.
Sourcepub async fn show_sparse_options(
&self,
scope: OptionScope,
target: Option<&str>,
) -> Result<SparseOptionMap>
pub async fn show_sparse_options( &self, scope: OptionScope, target: Option<&str>, ) -> Result<SparseOptionMap>
Shows indexed options and hooks as sparse arrays.
Sourcepub async fn set_option(
&self,
scope: OptionScope,
target: Option<&str>,
name: &str,
value: &OptionValue,
append: bool,
) -> Result<()>
pub async fn set_option( &self, scope: OptionScope, target: Option<&str>, name: &str, value: &OptionValue, append: bool, ) -> Result<()>
Sets an option or hook value.
Sourcepub async fn unset_option(
&self,
scope: OptionScope,
target: Option<&str>,
name: &str,
) -> Result<()>
pub async fn unset_option( &self, scope: OptionScope, target: Option<&str>, name: &str, ) -> Result<()>
Unsets an option or hook.
Sourcepub async fn environment(&self) -> Result<BTreeMap<String, Option<TmuxText>>>
pub async fn environment(&self) -> Result<BTreeMap<String, Option<TmuxText>>>
Shows the global tmux 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 global 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 global tmux 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 global 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 global tmux environment variable.
Sourcepub async fn remove_environment(&self, name: &str) -> Result<()>
pub async fn remove_environment(&self, name: &str) -> Result<()>
Removes a global variable while retaining it in tmux’s update list.
Sourcepub fn attach(
&self,
target: impl Into<SessionTarget>,
read_only: bool,
) -> Result<AttachedClient>
pub fn attach( &self, target: impl Into<SessionTarget>, read_only: bool, ) -> Result<AttachedClient>
Spawns an interactive tmux attachment with inherited standard streams.