def pane_dir(pane: P) -> Do: ui_pane = yield TmuxIO.from_either(UiPane.e_for(pane)) yield (ui_pane.cwd(pane) / TmuxIO.pure).get_or(lambda: TmuxIO.from_io(IO.delay(Path.cwd)))
def existing_window(session: Session, window: Window) -> Do: sid = yield TmuxIO.from_maybe(session.id, 'session has no id') wid = yield TmuxIO.from_maybe(window.id, 'window has no id') e = yield session_window(sid, wid) yield TmuxIO.from_either(e)
def tmux_data_cmd(cmd: str, args: List[str], cmd_data: TmuxCmdData[A]) -> Do: data = yield simple_tmux_cmd_attrs(cmd, args, cmd_data.attrs) yield TmuxIO.from_either(cons_tmux_data(data, cmd_data.cons))
def from_either_state(self, st: EitherState[E, S, A]) -> 'TmuxIOState[S, A]': return st.transform_f(TmuxIOState, lambda s: TmuxIO.from_either(s))
def from_either(self, e: Either[str, A]) -> 'TmuxIOState[S, A]': return TmuxIOState.lift(TmuxIO.from_either(e))
def inspect_either( self, f: Callable[[S], Either[str, A]]) -> 'TmuxIOState[S, A]': return TmuxIOState.inspect_f(lambda s: TmuxIO.from_either(f(s)))