@@ -147,8 +147,7 @@ def show_environment(self, name=None):
147
147
return vars_dict
148
148
149
149
150
- class tmux_cmd :
151
-
150
+ class TmuxCommand :
152
151
"""
153
152
:term:`tmux(1)` command via :py:mod:`subprocess`.
154
153
@@ -188,8 +187,8 @@ class tmux_cmd:
188
187
Notes
189
188
-----
190
189
191
- .. versionchanged :: 0.8
192
- Renamed from ``tmux`` to ``tmux_cmd``.
190
+ .. versionadded :: 0.8.4
191
+ Wrap to split execution from command from instance of it
193
192
"""
194
193
195
194
def __init__ (self , * args , ** kwargs ):
@@ -239,6 +238,38 @@ def execute(self):
239
238
return self
240
239
241
240
241
+ def tmux_cmd (* args , ** kwargs ):
242
+ """Wrapper around TmuxCommand. Executes instantly.
243
+
244
+ Examples
245
+ --------
246
+
247
+ .. code-block:: python
248
+
249
+ proc = tmux_cmd('new-session', '-s%' % 'my session')
250
+
251
+ if proc.stderr:
252
+ raise exc.LibTmuxException(
253
+ 'Command: %s returned error: %s' % (proc.cmd, proc.stderr)
254
+ )
255
+
256
+ print('tmux command returned %s' % proc.stdout)
257
+
258
+ Equivalent to:
259
+
260
+ .. code-block:: bash
261
+
262
+ $ tmux new-session -s my session
263
+
264
+ Notes
265
+ -----
266
+
267
+ .. versionchanged:: 0.8
268
+ Renamed from ``tmux`` to ``tmux_cmd``.
269
+ """
270
+ return TmuxCommand (* args , ** kwargs ).execute ()
271
+
272
+
242
273
class TmuxMappingObject (MutableMapping ):
243
274
244
275
r"""Base: :py:class:`MutableMapping`.
@@ -470,7 +501,7 @@ def get_version() -> LooseVersion:
470
501
:class:`distutils.version.LooseVersion`
471
502
tmux version according to :func:`libtmux.common.which`'s tmux
472
503
"""
473
- proc = tmux_cmd ("-V" ). execute ()
504
+ proc = tmux_cmd ("-V" )
474
505
if proc .stderr :
475
506
if proc .stderr [0 ] == "tmux: unknown option -- V" :
476
507
if sys .platform .startswith ("openbsd" ): # openbsd has no tmux -V
0 commit comments