@@ -143,7 +143,7 @@ def show_environment(self, name=None):
143143 return vars_dict
144144
145145
146- class tmux_cmd (object ):
146+ class TmuxCommand (object ):
147147
148148 """
149149 :term:`tmux(1)` command via :py:mod:`subprocess`.
@@ -184,8 +184,8 @@ class tmux_cmd(object):
184184 Notes
185185 -----
186186
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
189189 """
190190
191191 def __init__ (self , * args , ** kwargs ):
@@ -235,6 +235,38 @@ def execute(self):
235235 return self
236236
237237
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+
238270class TmuxMappingObject (MutableMapping ):
239271
240272 r"""Base: :py:class:`MutableMapping`.
@@ -459,7 +491,7 @@ def get_version():
459491 :class:`distutils.version.LooseVersion`
460492 tmux version according to :func:`libtmux.common.which`'s tmux
461493 """
462- proc = tmux_cmd ('-V' ). execute ()
494+ proc = tmux_cmd ('-V' )
463495 if proc .stderr :
464496 if proc .stderr [0 ] == 'tmux: unknown option -- V' :
465497 if sys .platform .startswith ("openbsd" ): # openbsd has no tmux -V
0 commit comments