@@ -141,11 +141,13 @@ def panes(self) -> QueryList["Pane"]:
141
141
#
142
142
# Command
143
143
#
144
- def cmd (self , cmd : str , * args : t .Any ) -> tmux_cmd :
144
+ def cmd (
145
+ self , cmd : str , * args : t .Any , target : t .Optional [t .Union [str , int ]] = None
146
+ ) -> tmux_cmd :
145
147
"""Execute tmux subcommand within session context.
146
148
147
- Automatically adds ``-t`` for object's session ID to the command. Pass ``-t``
148
- in args to override.
149
+ Automatically binds target by adding ``-t`` for object's session ID to the
150
+ command. Pass ``target`` to keyword arguments to override.
149
151
150
152
Examples
151
153
--------
@@ -158,6 +160,11 @@ def cmd(self, cmd: str, *args: t.Any) -> tmux_cmd:
158
160
... 'new-window', '-P', '-F#{window_id}').stdout[0], server=session.server)
159
161
Window(@... ...:..., Session($1 libtmux_...))
160
162
163
+ Parameters
164
+ ----------
165
+ target : str, optional
166
+ Optional custom target override. By default, the target is the session ID.
167
+
161
168
Returns
162
169
-------
163
170
:meth:`server.cmd`
@@ -170,6 +177,11 @@ def cmd(self, cmd: str, *args: t.Any) -> tmux_cmd:
170
177
"""
171
178
# if -t is not set in any arg yet
172
179
if not any ("-t" in str (x ) for x in args ):
180
+ # warnings.warn(
181
+ # "Use `target=...` instead of passing `-t` as an argument.",
182
+ # category=DeprecationWarning,
183
+ # stacklevel=2,
184
+ # )
173
185
# insert -t immediately after 1st arg, as per tmux format
174
186
new_args : t .Tuple [str , ...] = ()
175
187
assert isinstance (self .session_id , str )
0 commit comments