@@ -142,7 +142,7 @@ def show_environment(self, name=None):
142142 return vars_dict
143143
144144
145- class tmux_cmd (object ):
145+ class TmuxCommand (object ):
146146
147147 """
148148 :term:`tmux(1)` command via :py:mod:`subprocess`.
@@ -183,8 +183,8 @@ class tmux_cmd(object):
183183 Notes
184184 -----
185185
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
188188 """
189189
190190 def __init__ (self , * args , ** kwargs ):
@@ -234,6 +234,38 @@ def execute(self):
234234 return self
235235
236236
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+
237269class TmuxMappingObject (MutableMapping ):
238270
239271 r"""Base: :py:class:`MutableMapping`.
@@ -458,7 +490,7 @@ def get_version():
458490 :class:`distutils.version.LooseVersion`
459491 tmux version according to :func:`libtmux.common.which`'s tmux
460492 """
461- proc = tmux_cmd ("-V" ). execute ()
493+ proc = tmux_cmd ("-V" )
462494 if proc .stderr :
463495 if proc .stderr [0 ] == "tmux: unknown option -- V" :
464496 if sys .platform .startswith ("openbsd" ): # openbsd has no tmux -V
0 commit comments