Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

Python API

Python documentation

libtmux.Server.if_shell

Python

View as Markdown

Module
libtmux
Declared in
Server
Package
libtmux
Source
src/libtmux/server.py
Other languages
Ruby Lua TypeScript Rust GoJava.NET C++ Swift
if_shell ( self , shell_command : str , tmux_command : str , else_command : str | None = None , background : bool | None = None , target_pane : str | None = None ) → None
method [source]
method [source]
if_shell

Execute a tmux command conditionally via $ tmux if-shell.

Parameters
  • shell_command ( str ) – Shell command whose exit status determines which tmux command runs.

  • tmux_command ( str ) – Tmux command to run if *shell_command* succeeds (exit 0).

  • else_command ( str | None ) – Tmux command to run if *shell_command* fails (non-zero exit).

  • background ( bool | None ) – Run the shell command in the background (-b flag).

  • target_pane ( str | None ) – Target pane for format expansion (-t flag).

In other ports Run one tmux command or another, on a shell test

Examples

>>> server.if_shell('true', 'set -g @if_test yes')
>>> server.cmd('show-options', '-gv', '@if_test').stdout[0]
'yes'
await server.ifShell("test -d /tmp", "display-message 'present'");

0 declared, 0 inherited

Esc

Type to search.