Module commands

Source
Expand description

The commands module contains functions for building and executing tmux commands

§On This Page

Direct Initialization of Structure Fields

use tmux_interface::Tmux;

let mut tmux = Tmux::new();
tmux.verbose_logging = true;
use tmux_interface::Tmux;

let tmux = Tmux {
    verbose_logging: true,
    ..Default::default()
};

Using Builder Methods

  • Command Builder
    • One-liner
      • Autonomous
      • Binary
    • Multi-liner
      • Autonomous
      • Binary

§Tmux Commands

§Example

tmux [-2CluvV] [-c shell-command] [-f file] [-L socket-name] [-S socket-path]
[command [flags]]
NewSession::new() -> NewSession -> .build() -> TmuxCommand

Tmux::new() -> Tmux -> .build() -> TmuxCommand
(only tmux can be passed to std::process::Command)

For convenience all tmux commands builder are splitted in sub-modules by the similar principle as in tmux manual:

§Overview

Tmux commands

  • single
    • autonomous
    • binary
  • multiple
    • autonomous
    • binary

autonomous/binary - tmux commands can be called from outside of tmux (building one command sequence with tmux binary name) or from inside of tmux

multiple/single - tmux commands can be called as a single one or can be chained (similar as in shell)

§Single autonomous tmux command

Single tmux commands can be separated in two types:

  • autonomous tmux command, just a command itself and it’s arguments, used for invoking from inside of tmux

§Example

new-session -d -n name
use tmux_interface::NewSession;

let new_session = NewSession::new().detached().session_name("my_session").build();
  • binary tmux command, a command including tmux binary name and it’s arguments used for invoking from outside of tmux

§Example

tmux -v new-session -d -n name
use tmux_interface::{Tmux, NewSession};

let tmux = Tmux::with_command(
             NewSession::new()
               .detached()
               .session_name("my_session"))
             .verbose_logging()
             .build();

§Multiple tmux commands

And multiple tmux commands can be combined:

  • multiple tmux commands

§Example

new-session -d -n name ; attach-session -t name
use tmux_interface::TmuxCommands;

let cmds = TmuxCommands::new();
  • multiple tmux binary commands

§Example

tmux new-session -d -n name ; tmux attach-session -t name
use tmux_interface::{Tmux, TmuxCommands};

let cmds = Tmux::new().verbose_logging().commands(TmuxCommands::new());

§See Also:

Re-exports§

pub use tmux::StdIO;
pub use tmux::Tmux;
pub use tmux_command::TmuxCommand;
pub use tmux_commands::TmuxCommands;
pub use tmux_output::TmuxOutput;
pub use common::*;
pub use buffers::*;
pub use clients_and_sessions::*;
pub use global_and_session_environment::*;
pub use hooks::*;
pub use key_bindings::*;
pub use miscellaneous::*;
pub use options::*;
pub use status_line::*;
pub use windows_and_panes::*;

Modules§

buffers
clients_and_sessions
common
constants
global_and_session_environment
hooks
key_bindings
miscellaneous
options
status_line
tmux
tmux_command
tmux_commands
tmux_macro
tmux_output
windows_and_panes