Skip to main content

Server

Struct Server 

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

A cheap handle to one tmux server configuration.

Implementations§

Source§

impl Server

Source

pub async fn run_shell(&self, options: RunShell) -> Result<Option<TmuxText>>

Runs a shell or tmux command job.

Source

pub async fn wait_for(&self, channel: &str, action: WaitAction) -> Result<()>

Waits, signals, locks, or unlocks a named channel.

Source

pub async fn bind_key(&self, binding: KeyBinding) -> Result<()>

Creates or replaces a key binding.

Source

pub async fn unbind_key(&self, options: UnbindKey) -> Result<()>

Removes one or more key bindings.

Source

pub async fn list_keys( &self, table: Option<&str>, format: Option<&str>, ) -> Result<Vec<TmuxText>>

Lists key bindings as byte-preserving lines.

Source

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

Lists tmux commands, optionally narrowed by name.

Source

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

Locks every attached client.

Source

pub async fn server_access( &self, action: ServerAccess, ) -> Result<Option<Vec<TmuxText>>>

Applies or lists server ACL rules. Requires tmux 3.3+.

Source

pub async fn confirm_before(&self, options: ConfirmBefore) -> Result<()>

Opens a background confirmation prompt.

Source

pub async fn command_prompt(&self, options: CommandPrompt) -> Result<()>

Opens a background command prompt.

Source

pub async fn display_menu(&self, options: Menu) -> Result<()>

Displays an attached-client menu.

Source

pub async fn display(&self, options: DisplayMessage) -> Result<Option<TmuxText>>

Runs the broad server-scoped display-message operation.

Source

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

Starts the tmux daemon without creating a session.

Source

pub async fn show_messages( &self, client: Option<&ClientName>, terminals: bool, jobs: bool, ) -> Result<Vec<TmuxText>>

Shows server messages, terminal capabilities, or jobs.

Source

pub async fn refresh_client( &self, client: Option<&ClientName>, request_clipboard: bool, ) -> Result<()>

Refreshes a client display and optionally requests the clipboard.

Source

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+.

Source

pub async fn suspend_client(&self, client: Option<&ClientName>) -> Result<()>

Suspends an explicit or current client.

Source

pub async fn lock_client(&self, client: Option<&ClientName>) -> Result<()>

Locks an explicit or current client.

Source

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.

Source

pub async fn detach_all_clients( &self, keep: Option<&ClientName>, shell_command: Option<OsString>, ) -> Result<()>

Detaches all clients except an optional retained client.

Source

pub async fn if_shell(&self, options: IfShell) -> Result<()>

Executes one of two tmux commands based on a shell or format condition.

Source

pub async fn prompt_history( &self, prompt_type: Option<PromptType>, ) -> Result<Vec<TmuxText>>

Shows prompt history. Requires tmux 3.3+.

Source

pub async fn clear_prompt_history( &self, prompt_type: Option<PromptType>, ) -> Result<()>

Clears prompt history. Requires tmux 3.3+.

Source

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

Runs a named hook immediately.

Source

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.

Source

pub async fn unset_hook( &self, scope: HookScope, target: Option<&str>, name: &str, index: Option<u32>, ) -> Result<()>

Unsets one hook or sparse hook index.

Source

pub async fn show_hooks( &self, scope: HookScope, target: Option<&str>, ) -> Result<SparseOptionMap>

Shows hooks as sparse option arrays.

Source§

impl Server

Source

pub async fn buffers(&self) -> Result<Vec<Buffer>>

Lists paste buffers.

Source

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.

Source

pub async fn buffers_or_empty(&self) -> Vec<Buffer>

Lists buffers, returning an empty collection on failure.

Source

pub async fn buffer(&self, name: &BufferName) -> Result<Buffer>

Resolves an exact buffer name.

Source

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.

Source

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.

Source

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.

Source

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

Reads a named buffer or tmux’s most recent buffer.

Source

pub async fn delete_buffer(&self, name: Option<&BufferName>) -> Result<()>

Deletes a named buffer or tmux’s most recent buffer.

Source

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

Source

pub fn new() -> Self

Creates a handle using the tmux executable and default socket.

Source

pub fn builder() -> ServerBuilder

Starts configuring a server handle.

Source

pub fn from_environment() -> Result<Self>

Creates a server for the socket recorded in the TMUX environment variable.

Source

pub fn config(&self) -> &ServerConfig

Returns shared immutable configuration.

Source

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

Executes a command without treating a non-zero tmux exit status as an error.

Source

pub async fn version(&self) -> Result<&TmuxVersion>

Reads and caches the version reported by the configured executable.

Source

pub async fn sessions(&self) -> Result<Vec<Session>>

Lists sessions, preserving an error when the server is unavailable.

Source

pub async fn sessions_filtered( &self, filter: Option<&NativeFilter>, ) -> Result<Vec<Session>>

Lists sessions with an optional native tmux filter.

Source

pub async fn sessions_or_empty(&self) -> Vec<Session>

Lists sessions, returning an empty collection on discovery failure.

Source

pub async fn attached_sessions(&self) -> Result<Vec<Session>>

Lists sessions with at least one attached client.

Source

pub async fn session(&self, id: SessionId) -> Result<Session>

Resolves a session ID to a fresh snapshot.

Source

pub async fn session_by_name(&self, name: &SessionName) -> Result<Session>

Resolves an exact session name to a fresh snapshot.

Source

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

Lists every window link. A window linked into two sessions appears twice.

Source

pub async fn windows_filtered( &self, filter: Option<&NativeFilter>, ) -> Result<Vec<Window>>

Lists window links with an optional native tmux filter.

Source

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

Lists window links, returning an empty collection on discovery failure.

Source

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

Resolves a window ID. Fails loudly when the window has multiple links.

Source

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

Lists every pane with its parent identities.

Source

pub async fn panes_filtered( &self, filter: Option<&NativeFilter>, ) -> Result<Vec<Pane>>

Lists panes with an optional native tmux filter.

Source

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

Lists panes, returning an empty collection on discovery failure.

Source

pub async fn pane(&self, id: PaneId) -> Result<Pane>

Resolves a pane ID to a fresh snapshot.

Source

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

Lists attached tmux clients.

Source

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

Lists clients, returning an empty collection on discovery failure.

Source

pub async fn has_session(&self, name: &SessionName) -> Result<bool>

Returns whether an exact session name exists.

Source

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

Kills a selected session target.

Source

pub async fn new_session(&self, options: NewSession) -> Result<Session>

Creates a session and hydrates its initial snapshot.

Source

pub async fn with_session<F, Fut, T>( &self, options: NewSession, operation: F, ) -> Result<T>
where F: FnOnce(Session) -> Fut, Fut: Future<Output = Result<T>>,

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

Source

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

Kills the tmux server. A missing server is treated as already killed.

Source

pub async fn is_alive(&self) -> Result<bool>

Returns whether the configured tmux server responds.

Source

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

Returns a server-unavailable error unless tmux responds successfully.

Source

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

Resolves TMUX_PANE using this server’s socket configuration.

Source

pub async fn source_file(&self, path: impl AsRef<Path>) -> Result<()>

Sources a tmux configuration file.

Source

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.

Source

pub async fn display_message( &self, message: impl Into<OsString>, ) -> Result<TmuxText>

Displays a message and returns tmux’s byte-preserving expansion.

Source

pub async fn show_options( &self, scope: OptionScope, target: Option<&str>, ) -> Result<OptionMap>

Shows options at a scope and optional target.

Source

pub async fn show_sparse_options( &self, scope: OptionScope, target: Option<&str>, ) -> Result<SparseOptionMap>

Shows indexed options and hooks as sparse arrays.

Source

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

Sets an option or hook value.

Source

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

Unsets an option or hook.

Source

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

Shows the global tmux environment. Removed entries have a None value.

Source

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.

Source

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

Sets a global tmux environment variable.

Source

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.

Source

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

Unsets a global tmux environment variable.

Source

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

Removes a global variable while retaining it in tmux’s update list.

Source

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

Spawns an interactive tmux attachment with inherited standard streams.

Trait Implementations§

Source§

impl Clone for Server

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 Server

Source§

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

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

impl Default for Server

Source§

fn default() -> Self

Returns the “default value” for a type. 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