@@ -143,7 +143,7 @@ def show_environment(self, name=None):
143
143
return vars_dict
144
144
145
145
146
- class tmux_cmd (object ):
146
+ class TmuxCommand (object ):
147
147
148
148
"""
149
149
:term:`tmux(1)` command via :py:mod:`subprocess`.
@@ -184,8 +184,8 @@ class tmux_cmd(object):
184
184
Notes
185
185
-----
186
186
187
- .. versionchanged :: 0.8
188
- Renamed from ``tmux`` to ``tmux_cmd``.
187
+ .. versionadded :: 0.8.4
188
+ Wrap to split execution from command from instance of it
189
189
"""
190
190
191
191
def __init__ (self , * args , ** kwargs ):
@@ -235,6 +235,38 @@ def execute(self):
235
235
return self
236
236
237
237
238
+ def tmux_cmd (* args , ** kwargs ):
239
+ """Wrapper around TmuxCommand. Executes instantly.
240
+
241
+ Examples
242
+ --------
243
+
244
+ .. code-block:: python
245
+
246
+ proc = tmux_cmd('new-session', '-s%' % 'my session')
247
+
248
+ if proc.stderr:
249
+ raise exc.LibTmuxException(
250
+ 'Command: %s returned error: %s' % (proc.cmd, proc.stderr)
251
+ )
252
+
253
+ print('tmux command returned %s' % proc.stdout)
254
+
255
+ Equivalent to:
256
+
257
+ .. code-block:: bash
258
+
259
+ $ tmux new-session -s my session
260
+
261
+ Notes
262
+ -----
263
+
264
+ .. versionchanged:: 0.8
265
+ Renamed from ``tmux`` to ``tmux_cmd``.
266
+ """
267
+ return TmuxCommand (* args , ** kwargs ).execute ()
268
+
269
+
238
270
class TmuxMappingObject (MutableMapping ):
239
271
240
272
r"""Base: :py:class:`MutableMapping`.
@@ -459,7 +491,7 @@ def get_version():
459
491
:class:`distutils.version.LooseVersion`
460
492
tmux version according to :func:`libtmux.common.which`'s tmux
461
493
"""
462
- proc = tmux_cmd ('-V' ). execute ()
494
+ proc = tmux_cmd ('-V' )
463
495
if proc .stderr :
464
496
if proc .stderr [0 ] == 'tmux: unknown option -- V' :
465
497
if sys .platform .startswith ("openbsd" ): # openbsd has no tmux -V
0 commit comments