Skip to content

Commit 916523b

Browse files
committed
docs: Add tmuxp cli -c
1 parent ce71150 commit 916523b

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

CHANGES

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,31 @@ current
1212
Accepts tmux socket_name/socket_path, automatically uses the current
1313
tmux session and window and makes them available in pdb context.
1414

15-
In python 3.7+, supports ``PYTHONBREAKPOINT``::
15+
In python 3.7+, supports ``PYTHONBREAKPOINT``:
1616

17-
pip install ipdb
18-
env PYTHONBREAKPOINT=ipdb.set_trace tmuxp cli
17+
.. code-block:: sh
18+
19+
$ pip install ipdb
20+
$ env PYTHONBREAKPOINT=ipdb.set_trace tmuxp cli
21+
22+
You can execute python directly via ``-c``:
23+
24+
.. code-block:: sh
25+
26+
$ tmuxp cli -c 'print(session.name); print(window.name)'
27+
my_server
28+
my_window
29+
30+
$ tmuxp cli my_server -c 'print(session.name); print(window.name)'
31+
my_server
32+
my_window
33+
34+
$ tmuxp cli my_server my_window -c 'print(session.name); print(window.name)'
35+
my_server
36+
my_window
37+
38+
$ tmuxp cli my_server my_window -c 'print(window.name.upper())'
39+
MY_WINDOW
1940
2041
tmuxp 1.5.8 (2020-10-31)
2142
-----------------------

README.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@ current server, session, and window:
4545
[Pane(%6 Window(@3 1:your_window, Session($1 your_project)))
4646
4747
Python 3.7+ supports `PEP 553`_ ``breakpoint()`` (including
48-
``PYTHONBREAKPOINT``)
48+
``PYTHONBREAKPOINT``). Also supports direct commands via ``-c``:
49+
50+
.. code-block:: shell
51+
52+
$ tmuxp cli -c 'print(window.name)'
53+
my_window
54+
55+
$ tmuxp cli -c 'print(window.name.upper())'
56+
MY_WINDOW
4957
5058
Read more on `tmuxp CLI`_
5159

docs/cli.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ tmux CLI
3535

3636
tmuxp cli <session_name> <window_name>
3737

38+
tmuxp cli -c 'python code'
39+
3840
Launch into a `libtmux`_ session.
3941

4042
Automatically will picked the current tmux :class:`server <libtmux.Server>`,
@@ -62,8 +64,28 @@ compatible debuggers, for instance `ipdb`_:
6264

6365
.. code-block:: sh
6466
65-
pip install ipdb
66-
env PYTHONBREAKPOINT=ipdb.set_trace tmuxp cli
67+
$ pip install ipdb
68+
$ env PYTHONBREAKPOINT=ipdb.set_trace tmuxp cli
69+
70+
You can also pass in python code directly, similar to ``python -c``, do
71+
this via ``tmuxp -c``:
72+
73+
.. code-block:: shell
74+
75+
$ tmuxp cli -c 'print(session.name); print(window.name)'
76+
my_server
77+
my_window
78+
79+
$ tmuxp cli my_server -c 'print(session.name); print(window.name)'
80+
my_server
81+
my_window
82+
83+
$ tmuxp cli my_server my_window -c 'print(session.name); print(window.name)'
84+
my_server
85+
my_window
86+
87+
$ tmuxp cli my_server my_window -c 'print(window.name.upper())'
88+
MY_WINDOW
6789
6890
.. _PEP 553: https://www.python.org/dev/peps/pep-0553/
6991
.. _ipdb: https://pypi.org/project/ipdb/

0 commit comments

Comments
 (0)