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§

Modules§