Skip to content

Commit 4f8f095

Browse files
authored
Merge branch 'master' into plugin-system
2 parents e49f929 + a72297d commit 4f8f095

File tree

10 files changed

+438
-25
lines changed

10 files changed

+438
-25
lines changed

CHANGES

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,54 @@ current
1212
- :issue:`530` Add the plugin interface to the tmuxp package
1313
- :issue:`530` Add in depth documentation for the plugin system
1414
- *Insert changes/features/fixes for next release here*
15+
- :issue:`636` New command: ``tmuxp shell``
16+
17+
Automatically preloads session, window, and pane via `libtmux`_
18+
api objects and makes them available in a python console.
19+
20+
.. image:: _static/tmuxp-shell.gif
21+
:width: 100%
22+
23+
In python 3.7+, supports ``PYTHONBREAKPOINT``:
24+
25+
.. code-block:: sh
26+
27+
$ pip install ipdb
28+
$ env PYTHONBREAKPOINT=ipdb.set_trace tmuxp shell
29+
30+
You can execute python directly via ``-c``:
31+
32+
.. code-block:: sh
33+
34+
$ tmuxp shell -c 'print(session.name); print(window.name)'
35+
my_server
36+
my_window
37+
38+
$ tmuxp shell my_server -c 'print(session.name); print(window.name)'
39+
my_server
40+
my_window
41+
42+
$ tmuxp shell my_server my_window -c 'print(session.name); print(window.name)'
43+
my_server
44+
my_window
45+
46+
$ tmuxp shell my_server my_window -c 'print(window.name.upper())'
47+
MY_WINDOW
48+
49+
tmuxp 1.5.8 (2020-10-31)
50+
------------------------
51+
- :issue:`639` Passes start_directory through to new tmux session
52+
Fixes :issue:`631`, thank you @joseph-flinn!
53+
54+
tmuxp 1.5.7 (2020-10-31)
55+
------------------------
56+
- :issue:`637` Support for loading directories with periods in it
57+
58+
``tmuxp load ~/work/your.project`` will now work
59+
60+
Earlier workaround was to do ``tmuxp load ~/work/your.project/.tmuxp.yaml``
61+
62+
Fixes :issue:`212` and :issue:`201`
1563

1664
tmuxp 1.5.6 (2020-10-12)
1765
------------------------

README.rst

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,50 @@ Load your tmuxp config from anywhere by using the filename, assuming
8282
8383
See `author's tmuxp configs`_ and the projects' `tmuxp.yaml`_.
8484

85+
Shell
86+
-----
87+
*New in 1.6.0*:
88+
89+
``tmuxp shell`` launches into a python console preloaded with the attached server,
90+
session, and window in `libtmux`_ objects.
91+
92+
.. code-block:: shell
93+
94+
$ tmuxp shell
95+
96+
(Pdb) server
97+
<libtmux.server.Server object at 0x7f7dc8e69d10>
98+
(Pdb) server.sessions
99+
[Session($1 your_project)]
100+
(Pdb) session
101+
Session($1 your_project)
102+
(Pdb) session.name
103+
'your_project'
104+
(Pdb) window
105+
Window(@3 1:your_window, Session($1 your_project))
106+
(Pdb) window.name
107+
'your_window'
108+
(Pdb) window.panes
109+
[Pane(%6 Window(@3 1:your_window, Session($1 your_project)))
110+
(Pdb) pane
111+
Pane(%6 Window(@3 1:your_window, Session($1 your_project))
112+
113+
Python 3.7+ supports `PEP 553`_ ``breakpoint()`` (including
114+
``PYTHONBREAKPOINT``). Also supports direct commands via ``-c``:
115+
116+
.. code-block:: shell
117+
118+
$ tmuxp shell -c 'print(window.name)'
119+
my_window
120+
121+
$ tmuxp shell -c 'print(window.name.upper())'
122+
MY_WINDOW
123+
124+
Read more on `tmuxp shell`_ in the CLI docs.
125+
126+
.. _PEP 553: https://www.python.org/dev/peps/pep-0553/
127+
.. _tmuxp shell: https://tmuxp.git-pull.com/cli.html#shell
128+
85129
Pre-load hook
86130
-------------
87131
Run custom startup scripts (such as installing project dependencies before
@@ -146,7 +190,6 @@ See the `Quickstart`_.
146190
147191
Want to learn more about tmux itself? `Read The Tao of Tmux online`_.
148192
149-
.. _tmuxp on Travis CI: http://travis-ci.org/tmux-python/tmuxp
150193
.. _Documentation: http://tmuxp.git-pull.com
151194
.. _Source: https://github.com/tmux-python/tmuxp
152195
.. _中文: http://tmuxp-zh.rtfd.org/
@@ -163,7 +206,6 @@ Want to learn more about tmux itself? `Read The Tao of Tmux online`_.
163206
.. _freezing tmux: http://tmuxp.git-pull.com/cli.html#freeze-sessions
164207
.. _Plugin System: http://tmuxp.git-pull.com/plugin_system.html
165208
.. _bootstrap_env.py: https://github.com/tmux-python/tmuxp/blob/master/bootstrap_env.py
166-
.. _travis.yml: http://tmuxp.git-pull.com/developing.html#travis-ci
167209
.. _testing: http://tmuxp.git-pull.com/developing.html#test-runner
168210
.. _python objects: http://tmuxp.git-pull.com/api.html#api
169211
.. _tmuxp.yaml: https://github.com/tmux-python/tmuxp/blob/master/.tmuxp.yaml
@@ -210,9 +252,9 @@ Project details
210252
:alt: Docs
211253
:target: https://github.com/tmux-python/tmuxp/actions?query=workflow%3A"Publish+Docs"
212254
213-
.. |build-status| image:: https://img.shields.io/travis/tmux-python/tmuxp.svg
214-
:alt: Build Status
215-
:target: https://travis-ci.org/tmux-python/tmuxp
255+
.. |build-status| image:: https://github.com/tmux-python/tmuxp/workflows/tests/badge.svg
256+
:alt: Build status
257+
:target: https://github.com/tmux-python/tmuxp/actions?query=workflow%3A"tests"
216258
217259
.. |coverage| image:: https://codecov.io/gh/tmux-python/tmuxp/branch/master/graph/badge.svg
218260
:alt: Code Coverage

docs/_static/tmuxp-shell.gif

150 KB
Loading

docs/cli.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,85 @@ In zsh (``~/.zshrc``):
2222
2323
eval "$(_TMUXP_COMPLETE=source_zsh tmuxp)"
2424
25+
.. _cli_shell:
26+
27+
Shell
28+
-----
29+
30+
::
31+
32+
tmuxp shell
33+
34+
tmuxp shell <session_name>
35+
36+
tmuxp shell <session_name> <window_name>
37+
38+
tmuxp shell -c 'python code'
39+
40+
Launch into a python console with `libtmux`_ objects. Compare to django's shell.
41+
42+
.. image:: _static/tmuxp-shell.gif
43+
:width: 100%
44+
45+
Automatically preloads current tmux :class:`server <libtmux.Server>`,
46+
:class:`session <libtmux.Session>`, :class:`window <libtmux.Window>`
47+
:class:`pane <libtmux.Pane>`. Pass additional arguments to select a
48+
specific one of your choice::
49+
50+
(Pdb) server
51+
<libtmux.server.Server object at 0x7f7dc8e69d10>
52+
(Pdb) server.sessions
53+
[Session($1 your_project)]
54+
(Pdb) session
55+
Session($1 your_project)
56+
(Pdb) session.name
57+
'your_project'
58+
(Pdb) window
59+
Window(@3 1:your_window, Session($1 your_project))
60+
(Pdb) window.name
61+
'your_window'
62+
(Pdb) window.panes
63+
[Pane(%6 Window(@3 1:your_window, Session($1 your_project)))
64+
(Pdb) pane
65+
Pane(%6 Window(@3 1:your_window, Session($1 your_project)))
66+
67+
Python 3.7 supports `PEP 553`_'s ``PYTHONBREAKPOINT`` and supports
68+
compatible debuggers, for instance `ipdb`_:
69+
70+
.. code-block:: sh
71+
72+
$ pip install ipdb
73+
$ env PYTHONBREAKPOINT=ipdb.set_trace tmuxp shell
74+
75+
You can also pass in python code directly, similar to ``python -c``, do
76+
this via ``tmuxp -c``:
77+
78+
.. code-block:: shell
79+
80+
$ tmuxp shell -c 'print(session.name); print(window.name)'
81+
my_server
82+
my_window
83+
84+
$ tmuxp shell my_server -c 'print(session.name); print(window.name)'
85+
my_server
86+
my_window
87+
88+
$ tmuxp shell my_server my_window -c 'print(session.name); print(window.name)'
89+
my_server
90+
my_window
91+
92+
$ tmuxp shell my_server my_window -c 'print(window.name.upper())'
93+
MY_WINDOW
94+
95+
# Assuming inside a tmux pane or one is attached on default server
96+
$ tmuxp shell -c 'print(pane.id); print(pane.window.name)'
97+
%2
98+
my_window
99+
100+
.. _PEP 553: https://www.python.org/dev/peps/pep-0553/
101+
.. _ipdb: https://pypi.org/project/ipdb/
102+
.. _libtmux: https://libtmux.git-pull.com
103+
25104
.. _cli_freeze:
26105

27106
Freeze sessions

docs/developing.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.. module:: tmuxp
2-
31
.. _developing:
42

53
======================
@@ -216,17 +214,17 @@ this will load the ``.tmuxp.yaml`` in the root of the project.
216214
.. literalinclude:: ../.tmuxp.yaml
217215
:language: yaml
218216

219-
.. _travis:
217+
.. _gh_actions:
220218

221-
Travis CI
222-
---------
219+
Github Actions
220+
--------------
223221

224-
tmuxp uses `travis-ci`_ for continuous integration / automatic unit
222+
tmuxp uses `github actions`_ for continuous integration / automatic unit
225223
testing.
226224

227-
To view the tmux and python versions tested see the `.travis.yml`_.
225+
To view the tmux and python versions tested see the `.github/workflows/tests.yml`_.
228226
Builds are done on ``master`` and pull requests and can be viewed on
229-
the `travis build site`_.
227+
the `gh build site`_.
230228

231229
Testing options
232230
---------------
@@ -236,12 +234,12 @@ tests are being stubborn.
236234

237235
e.g. ``RETRY_TIMEOUT_SECONDS=10 py.test``
238236

239-
.. literalinclude:: ../.travis.yml
237+
.. literalinclude:: ../.github/workflows/tests.yml
240238
:language: yaml
241239

242240
.. _py.test usage argument: https://pytest.org/latest/usage.html
243241
.. _entr: http://entrproject.org/
244-
.. _travis-ci: http://www.travis-ci.org
245-
.. _travis build site: http://www.travis-ci.org/tmux-python/tmuxp
246-
.. _.travis.yml: https://github.com/tmux-python/tmuxp/blob/master/.travis.yml
242+
.. _github actions: https://github.com/features/actions
243+
.. _gh build site: https://github.com/tmux-python/tmuxp/actions?query=workflow%3Atests
244+
.. _.github/workflows/tests.yml: https://github.com/tmux-python/tmuxp/blob/master/.github/workflows/tests.yml
247245
.. _issue on github: https://github.com/tmux-python/tmuxp/issues

tests/conftest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@
1212

1313

1414
@pytest.fixture(scope='function')
15-
def server(request):
15+
def socket_name(request):
16+
return 'tmuxp_test%s' % next(namer)
17+
18+
19+
@pytest.fixture(scope='function')
20+
def server(request, socket_name):
1621
t = Server()
17-
t.socket_name = 'tmuxp_test%s' % next(namer)
22+
t.socket_name = socket_name
1823

1924
def fin():
2025
t.kill_server()

0 commit comments

Comments
 (0)