AntonGepting / tmux-interface-rs

Rust language library for communication with TMUX via CLI
MIT License
52 stars 6 forks source link
cli interface rust tmux

tmux_interface

Build Status Crates.io Documentation

Description

tmux_interface is a library for communication with TMUX via CLI written in Rust programming language. The crate documentation can be found on the docs.rs page.

Usage

  1. Add a dependency in your Cargo.toml. Versions below 1.0.0 are mostly for development and testing purposes (use them in your projects on your own risk, further versions may have different API).

     [dependencies]
     tmux_interface = "1.0.0"
  2. Add extern crate in your source file.

     extern crate tmux_interface;
  3. Use it's functions

    Example 1

     use tmux_interface::{HasSession, KillSession, NewSession, NewWindow, SplitWindow, Tmux};
    
     let target_session = "example_1";
    
     // tmux new -d -s example_1 ; neww ; splitw -v
     Tmux::new()
         .add_command(NewSession::new().detached().session_name(target_session))
         .add_command(NewWindow::new())
         .add_command(SplitWindow::new().vertical())
         .output()
         .unwrap();
    
     // tmux has -t example_1
     let status = Tmux::with_command(HasSession::new().target_session(target_session))
         .status()
         .unwrap()
         .success();
    
     assert!(status);
    
     // tmux kill-session -t example_1
     Tmux::with_command(KillSession::new().target_session(target_session))
         .output()
         .unwrap();
    

Testing

The library is still in experimental development stage (unstable).

The library was tested using GitHub Actions under following conditions:

Contributors

License

tmux_interface library is licensed under the MIT license. Please read the license file in the repository for more information.

See also