@@ -147,8 +147,7 @@ def show_environment(self, name=None):
147147 return vars_dict
148148
149149
150- class tmux_cmd :
151-
150+ class TmuxCommand :
152151 """
153152 :term:`tmux(1)` command via :py:mod:`subprocess`.
154153
@@ -188,8 +187,8 @@ class tmux_cmd:
188187 Notes
189188 -----
190189
191- .. versionchanged :: 0.8
192- Renamed from ``tmux`` to ``tmux_cmd``.
190+ .. versionadded :: 0.8.4
191+ Wrap to split execution from command from instance of it
193192 """
194193
195194 def __init__ (self , * args , ** kwargs ):
@@ -239,6 +238,38 @@ def execute(self):
239238 return self
240239
241240
241+ def tmux_cmd (* args , ** kwargs ):
242+ """Wrapper around TmuxCommand. Executes instantly.
243+
244+ Examples
245+ --------
246+
247+ .. code-block:: python
248+
249+ proc = tmux_cmd('new-session', '-s%' % 'my session')
250+
251+ if proc.stderr:
252+ raise exc.LibTmuxException(
253+ 'Command: %s returned error: %s' % (proc.cmd, proc.stderr)
254+ )
255+
256+ print('tmux command returned %s' % proc.stdout)
257+
258+ Equivalent to:
259+
260+ .. code-block:: bash
261+
262+ $ tmux new-session -s my session
263+
264+ Notes
265+ -----
266+
267+ .. versionchanged:: 0.8
268+ Renamed from ``tmux`` to ``tmux_cmd``.
269+ """
270+ return TmuxCommand (* args , ** kwargs ).execute ()
271+
272+
242273class TmuxMappingObject (MutableMapping ):
243274
244275 r"""Base: :py:class:`MutableMapping`.
@@ -470,7 +501,7 @@ def get_version() -> LooseVersion:
470501 :class:`distutils.version.LooseVersion`
471502 tmux version according to :func:`libtmux.common.which`'s tmux
472503 """
473- proc = tmux_cmd ("-V" ). execute ()
504+ proc = tmux_cmd ("-V" )
474505 if proc .stderr :
475506 if proc .stderr [0 ] == "tmux: unknown option -- V" :
476507 if sys .platform .startswith ("openbsd" ): # openbsd has no tmux -V
0 commit comments