@@ -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 ):
@@ -239,6 +239,38 @@ def execute(self):
239239 return self
240240
241241
242+ def tmux_cmd (* args , ** kwargs ):
243+ """Wrapper around TmuxCommand. Executes instantly.
244+
245+ Examples
246+ --------
247+
248+ .. code-block:: python
249+
250+ proc = tmux_cmd('new-session', '-s%' % 'my session')
251+
252+ if proc.stderr:
253+ raise exc.LibTmuxException(
254+ 'Command: %s returned error: %s' % (proc.cmd, proc.stderr)
255+ )
256+
257+ print('tmux command returned %s' % proc.stdout)
258+
259+ Equivalent to:
260+
261+ .. code-block:: bash
262+
263+ $ tmux new-session -s my session
264+
265+ Notes
266+ -----
267+
268+ .. versionchanged:: 0.8
269+ Renamed from ``tmux`` to ``tmux_cmd``.
270+ """
271+ return TmuxCommand (* args , ** kwargs ).execute ()
272+
273+
242274class TmuxMappingObject (MutableMapping ):
243275
244276 r"""Base: :py:class:`MutableMapping`.
@@ -463,7 +495,7 @@ def get_version():
463495 :class:`distutils.version.LooseVersion`
464496 tmux version according to :func:`libtmux.common.which`'s tmux
465497 """
466- proc = tmux_cmd ('-V' ). execute ()
498+ proc = tmux_cmd ('-V' )
467499 if proc .stderr :
468500 if proc .stderr [0 ] == 'tmux: unknown option -- V' :
469501 if sys .platform .startswith ("openbsd" ): # openbsd has no tmux -V
0 commit comments