Skip to content

Commit 173497c

Browse files
committed
rc4. New example for focusing panes. Fix bug where focus: pane would break when loading with tmux session.
1 parent 1a1f1dc commit 173497c

10 files changed

+112
-93
lines changed

CHANGES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ Changelog
44

55
Here you can find the recent changes to tmuxp.
66

7+
0.1-rc4
8+
-------
9+
10+
- [bug] fix bug were ``focus: true`` would not launch sessions when using
11+
``$ tmuxp load`` in a tmux session.
12+
713
0.1-rc3
814
-------
915

1016
- [bug] [tests] `Issue #25`_ - ``focus: true`` not working in panes. Add
1117
tests for focusing panes in config.
1218
- [internal] :meth:`Pane.select_pane()`.
19+
- [docs] add new example for ``focus: true``.
1320

1421
.. _Issue #25: https://github.com/tony/tmuxp/issues/25
1522

doc/examples.rst

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,8 @@ JSON
5858
.. literalinclude:: ../examples/blank-panes.json
5959
:language: json
6060

61-
Start Directory
62-
---------------
63-
64-
Equivalent to ``tmux new-window -c <start-directory>``.
65-
66-
YAML
67-
""""
68-
69-
.. literalinclude:: ../examples/start-directory.yaml
70-
:language: yaml
71-
72-
JSON
73-
""""
74-
75-
.. literalinclude:: ../examples/start-directory.json
76-
:language: json
77-
78-
2 split panes
79-
-------------
61+
2 panes
62+
-------
8063

8164
.. sidebar:: 2 pane
8265

@@ -92,30 +75,18 @@ JSON
9275
| |
9376
+-----------------+
9477

95-
YAML - Short form
96-
"""""""""""""""""
78+
YAML
79+
""""
9780

9881
.. literalinclude:: ../examples/2-pane-vertical.yaml
9982
:language: yaml
10083

101-
JSON - Short form
102-
"""""""""""""""""
84+
JSON
85+
""""
10386

10487
.. literalinclude:: ../examples/2-pane-vertical.json
10588
:language: json
10689

107-
YAML - Christmas Tree
108-
"""""""""""""""""""""
109-
110-
.. literalinclude:: ../examples/2-pane-vertical-long.yaml
111-
:language: yaml
112-
113-
JSON - Christmas Tree
114-
"""""""""""""""""""""
115-
116-
.. literalinclude:: ../examples/2-pane-vertical-long.json
117-
:language: json
118-
11990
3 panes
12091
-------
12192

@@ -174,7 +145,41 @@ JSON
174145
.. literalinclude:: ../examples/4-pane.json
175146
:language: json
176147

148+
Start Directory
149+
---------------
150+
151+
Equivalent to ``tmux new-window -c <start-directory>``.
152+
153+
YAML
154+
""""
177155

156+
.. literalinclude:: ../examples/start-directory.yaml
157+
:language: yaml
158+
159+
JSON
160+
""""
161+
162+
.. literalinclude:: ../examples/start-directory.json
163+
:language: json
164+
165+
Focusing
166+
--------
167+
168+
tmuxp allows ``focus: true`` for assuring windows and panes are attached /
169+
selected upon loading.
170+
171+
YAML
172+
""""
173+
174+
.. literalinclude:: ../examples/focus-window-and-panes.yaml
175+
:language: yaml
176+
177+
JSON
178+
""""
179+
180+
.. literalinclude:: ../examples/focus-window-and-panes.json
181+
:language: json
182+
178183
Automatic Rename
179184
----------------
180185

examples/2-pane-vertical-long.json

Lines changed: 0 additions & 37 deletions
This file was deleted.

examples/2-pane-vertical-long.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/focus-window-and-panes.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"windows": [
3+
{
4+
"panes": [
5+
{
6+
"shell_command": [
7+
"pwd",
8+
"echo 'this pane should be selected on load'"
9+
],
10+
"focus": true
11+
},
12+
{
13+
"shell_command": [
14+
"cd /var/log",
15+
"pwd"
16+
]
17+
}
18+
],
19+
"window_name": "attached window on load",
20+
"focus": true
21+
},
22+
{
23+
"panes": [
24+
"pane",
25+
{
26+
"shell_command": [
27+
"echo 'this pane should be focused, when window switched to first time'"
28+
],
29+
"focus": true
30+
},
31+
"pane"
32+
],
33+
"shell_command_before": "cd /var/www",
34+
"window_name": "second window"
35+
}
36+
],
37+
"session_name": "focus window and pane when loading sessions"
38+
}

examples/focus-window-and-panes.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
session_name: focus
2+
windows:
3+
- window_name: attached window
4+
focus: true
5+
panes:
6+
- shell_command:
7+
- pwd
8+
- echo 'this pane should be selected on load'
9+
focus: true
10+
- shell_command:
11+
- cd /var/log
12+
- pwd
13+
- window_name: second window
14+
shell_command_before: cd /var/log
15+
panes:
16+
- pane
17+
- shell_command:
18+
- echo 'this pane should be focused, when window switched to first time'
19+
focus: true
20+
- pane

tmuxp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121

2222
import logging
2323

24-
__version__ = '0.1.0rc2'
24+
__version__ = '0.1.0rc4'

tmuxp/util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ def by(val, *args):
188188
return list(filter(by, self.children))
189189

190190
def getById(self, id):
191-
"""Return object based on `.get()`_ from `backbone.js`_.
191+
"""Return object based on ``childIdAttribute``.
192+
193+
Based on `.get()`_ from `backbone.js`_.
192194
193195
.. _backbone.js: http://backbonejs.org/
194196
.. _.get(): http://backbonejs.org/#Collection-get

tmuxp/window.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ def select_window(self):
295295
:rtype: :class:`Window`
296296
297297
"""
298-
return self.session.select_window(self.get('window_id'))
298+
target = '%s:%s' % (self.get('session_id'), self.get('window_index')),
299+
return self.session.select_window(target)
299300

300301
def select_pane(self, target_pane):
301302
"""Return selected :class:`Pane` through ``$ tmux select-pane``.

tmuxp/workspacebuilder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def iter_create_windows(self, s):
196196
w.set_window_option(key, val)
197197

198198
if 'focus' in wconf and wconf['focus']:
199-
s.select_window(w['window_id'])
199+
w.select_window()
200200

201201
s.server._update_windows()
202202

0 commit comments

Comments
 (0)