@@ -230,8 +230,101 @@ Method 1: Use passthrough to tmux's ``target`` system.
230230
231231 >> > session.kill_window(" ha in" )
232232
233- .. code-block ::
233+ The window in the bg dissapeared. This was the equivalent of ``$ tmux kill-window -t'ha in' ``
234+
235+ Internally, tmux uses ``target ``. It's specific behavior depends on what the target is, view
236+ the manpage for tmux for more.
237+
238+ This section contains a list of the commands supported by tmux. Most commands accept the
239+ optional -t argument with one of target-client, target-session target-window, or target-pane.
240+
241+ In this case, you can also go back in time an recreate the window again. The CLI should have history,
242+ so press the up arrow key should work.
243+
244+ .. code-block :: python
245+
246+ >> > session.new_window(attach = False , window_name = " ha in the bg" )
247+ Window(@ 11 3 :ha in the bg, Session($ 3 a_tmuxp_session))
248+
249+ Try to kill by the ``@[0-9999] `` the created window gave you.
250+
251+ .. code-block :: python
252+
253+ >> > session.new_window(attach = False , window_name = " ha in the bg" )
254+ Window(@ 12 3 :ha in the bg, Session($ 3 a_tmuxp_session))
255+
256+
257+ .. code-block :: python
258+
259+ >> > session.kill_window(' @12' )
260+
261+ In addition, you could also ``.kill_window `` direction from the :class: `Window `
262+ object:
263+
264+ .. code-block :: python
265+
266+ >> > window = session.new_window(attach = False , window_name = " check this out" )
267+
268+ And kill:
269+
270+ .. code-block :: python
271+ >> > window.kill_window()
272+
273+ And of course, you can use :meth: `Session.list_windows() ` and :meth: `Session.findWhere() `
274+ to list and sort through active :class: `Window `'s.
275+
276+ Manipulating windows
277+ --------------------
278+
279+ Now that we know how to create windows, let's use one. Let's use :meth: `Session.attached_window() `
280+ to grab our current window.
281+
282+ .. code-block :: python
283+
284+ >> > window = session.attached_window()
285+
286+ ``window `` now has access to all of the objects inside of :class: `Window `.
287+
288+ Let's create a pane, :meth: `Window.split_window `:
289+
290+ .. code-block :: python
291+
292+ >> > window.split_window(attach = False )
293+ Pane(% 23 Window(@ 10 1 :tmuxp_wins, Session($ 3 a_tmuxp_session)))
294+
295+ Powered up. Let's have a break down:
296+
297+ 1. ``window = session.attached_window() `` gave us the :class: `Window ` of the current attached to window.
298+ 2. ``attach=False `` assures the cursor didn't switch to the newly created pane.
299+ 3. Returned the created :class: `Pane `.
300+
301+ Also, since you are aware of this power, let's commemorate the experience:
302+
303+ .. code-block :: python
304+
305+ >> > window.rename_window(' tmuxpower' )
306+ Window(@ 10 1 :tmuxpower, Session($ 3 a_tmuxp_session))
307+
308+ You should have noticed :meth: `Window.rename_window ` renamed the window.
309+
310+ Final notes
311+ -----------
312+
313+ These objects created use tmux's internal usage of ID's to make servers,
314+ sessions, windows and panes accessible at the object level.
315+
316+ You don't have to see the tmux session to be able to orchestrate it. After
317+ all, :class: `WorkspaceBuilder ` uses these same internals to build your
318+ sessions in the background. :)
319+
320+ .. seealso ::
321+
322+ If you want to dig deeper, check out :ref: `API `, the code for
323+ `workspacebuilder.py `_ and our `testsuite `_ (see :ref: `developing `.)
324+
234325
235326.. _sliderepl : http://discorporate.us/projects/sliderepl/
236327.. _backbone : http:/ /backbonejs.org
237328.. _Backbone.Collection.prototype.findWhere : http://backbonejs.org/#Collection-findWhere
329+ .. _workspacebuilder.py : https://github.com/tony/tmuxp/blob/master/tmuxp/workspacebuilder.py
330+ .. _testsuite : https://github.com/tony/tmuxp/tree/master/tmuxp/testsuite
0 commit comments