Skip to main content

TmuxSessionBuilder

Struct TmuxSessionBuilder 

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

Builder that accumulates tmux operations for creating and configuring a session.

Can either execute operations against a live tmux server or return them as command strings for testing and dry-run.

§Examples

use git_paw::tmux::{TmuxSessionBuilder, PaneSpec};

let session = TmuxSessionBuilder::new("my-project")
    .add_pane(PaneSpec {
        branch: "feat/auth".into(),
        worktree: "/tmp/my-project-feat-auth".into(),
        cli_command: "claude".into(),
    })
    .mouse_mode(true)
    .build()?;

// Dry-run: inspect commands
for cmd in session.command_strings() {
    println!("{cmd}");
}

// Or execute for real
session.execute()?;

Implementations§

Source§

impl TmuxSessionBuilder

Source

pub fn new(project_name: &str) -> Self

Create a new builder for the given project name.

The session will be named paw-<project_name> unless overridden with session_name.

Source

pub fn session_name(self, name: String) -> Self

Override the session name instead of deriving it from the project name.

Use this with resolve_session_name to handle name collisions.

Source

pub fn add_pane(self, spec: PaneSpec) -> Self

Add a pane that will cd into the worktree and run the CLI command.

Source

pub fn mouse_mode(self, enabled: bool) -> Self

Enable or disable mouse mode for the session (default: true).

When enabled, users can click to switch panes, drag borders to resize, and scroll. This is set per-session and does not affect other tmux sessions.

Source

pub fn border_affordances(self, enabled: bool) -> Self

Enable or disable the border affordances for the session (default: true).

When enabled, the session receives heavy borders, dim/active border styling, and a per-pane label strip, and each pane’s title is set to its role/branch id. When disabled, none of these set-option or select-pane -T invocations are emitted and the session inherits the user’s default tmux styling. Driven by [layout].border_affordances.

Source

pub fn set_environment(self, key: &str, value: &str) -> Self

Set a session-level environment variable.

The resulting tmux set-environment -t <session> <key> <value> command is emitted before any send-keys commands so all panes inherit it.

Source

pub fn build(self) -> Result<TmuxSession, PawError>

Build the full sequence of tmux commands without executing anything.

Returns a TmuxSession that can be executed or inspected. Returns an error if no panes have been added.

Trait Implementations§

Source§

impl Debug for TmuxSessionBuilder

Source§

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

Formats the value using the given formatter. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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