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