Skip to content

Commit 6108748

Browse files
committed
Update changes. Update config.inline and add tests. Updates to test_config to remove start_directory from panes
1 parent dcf6b88 commit 6108748

File tree

3 files changed

+61
-38
lines changed

3 files changed

+61
-38
lines changed

CHANGES

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ Here you can find the recent changes to tmuxp.
66
0.1-dev
77
-------
88

9+
2013-11-08
10+
''''''''''
11+
12+
- [cli] [freeze] - ``$ tmuxp freeze`` will now freeze a window with a
13+
``start_directory`` when all panes in a window are inside the same
14+
directory.
15+
- [cli] [config] [tests] :meth:`config.inline` will now turn panes with no
16+
other attributes and 1 command into a single item value.
17+
18+
.. code-block:: yaml
19+
20+
- panes:
21+
- shell_command: top
22+
23+
# will now inline to:
24+
25+
- panes
26+
- top
27+
28+
This will improve ``$ tmuxp freeze``
29+
930
2013-11-07
1031
''''''''''
1132

tmuxp/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ def inline(sconf):
109109

110110
if ('shell_command' in sconf and isinstance(sconf['shell_command'], list) and len(sconf['shell_command']) == 1):
111111
sconf['shell_command'] = sconf['shell_command'][0]
112+
113+
if len(sconf.keys()) == int(1):
114+
sconf = sconf['shell_command']
112115
if ('shell_command_before' in sconf and isinstance(sconf['shell_command_before'], list) and len(sconf['shell_command_before']) == 1):
113116
sconf['shell_command_before'] = sconf['shell_command_before'][0]
114117

tmuxp/testsuite/test_config.py

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
logger = logging.getLogger(__name__)
1414
TMUXP_DIR = os.path.join(os.path.dirname(__file__), '.tmuxp')
1515
current_dir = os.path.abspath(os.path.dirname(__file__))
16-
example_dir = os.path.abspath(os.path.join(current_dir, '..', '..', 'examples'))
16+
example_dir = os.path.abspath(os.path.join(
17+
current_dir, '..', '..', 'examples'))
1718

1819

1920
sampleconfigdict = {
@@ -139,12 +140,17 @@ class ExpandTest(TestCase):
139140
'session_name': 'sampleconfig',
140141
'start_directory': '~',
141142
'windows': [{
142-
'shell_command': 'top',
143143
'window_name': 'editor',
144144
'panes': [
145+
{
146+
'shell_command': [
147+
'vim',
148+
'top'
149+
]
150+
},
145151
{
146152
'shell_command': ['vim'],
147-
},
153+
},
148154
{
149155
'shell_command': 'cowsay "hey"'
150156
},
@@ -200,12 +206,15 @@ class ExpandTest(TestCase):
200206
'start_directory': '~',
201207
'windows': [
202208
{
203-
'shell_command': ['top'],
204209
'window_name': 'editor',
205210
'panes': [
211+
{
212+
'shell_command': ['vim', 'top'],
213+
},
206214
{
207215
'shell_command': ['vim'],
208-
}, {
216+
},
217+
{
209218
'shell_command': ['cowsay "hey"']
210219
},
211220
],
@@ -274,7 +283,7 @@ class InlineTest(TestCase):
274283
'window_name': 'editor',
275284
'panes': [
276285
{
277-
'start_directory': '~', 'shell_command': ['vim'],
286+
'shell_command': ['vim'],
278287
}, {
279288
'shell_command': ['cowsay "hey"']
280289
},
@@ -284,8 +293,9 @@ class InlineTest(TestCase):
284293
{
285294
'window_name': 'logging',
286295
'panes': [
287-
{'shell_command': ['tail -F /var/log/syslog'],
288-
'start_directory':'/var/log'}
296+
{
297+
'shell_command': ['tail -F /var/log/syslog'],
298+
}
289299
]
290300
},
291301
{
@@ -305,35 +315,26 @@ class InlineTest(TestCase):
305315
'shell_command': 'top',
306316
'window_name': 'editor',
307317
'panes': [
308-
{
309-
'start_directory': '~',
310-
'shell_command': 'vim',
311-
},
312-
{
313-
'shell_command': 'cowsay "hey"'
314-
},
318+
'vim',
319+
'cowsay "hey"'
315320
],
316321
'layout': 'main-verticle'
317322
},
318323
{
319324
'window_name': 'logging',
320325
'panes': [
321-
{
322-
'shell_command': 'tail -F /var/log/syslog',
323-
'start_directory': '/var/log'
324-
}
326+
'tail -F /var/log/syslog',
325327
]
326328
},
327329
{
328330
'options': {
329331
'automatic_rename': True,
330332
},
331333
'panes': [
332-
{
333-
'shell_command': 'htop'
334-
}
334+
'htop'
335335
]
336-
}
336+
},
337+
337338
]
338339
}
339340

@@ -358,7 +359,6 @@ class InheritanceTest(TestCase):
358359
'start_directory': '~',
359360
'panes': [
360361
{
361-
'start_directory': '~',
362362
'shell_command': ['vim'],
363363
},
364364
{
@@ -372,7 +372,6 @@ class InheritanceTest(TestCase):
372372
'panes': [
373373
{
374374
'shell_command': ['tail -F /var/log/syslog'],
375-
'start_directory':'/var/log'
376375
}
377376
]
378377
},
@@ -381,7 +380,6 @@ class InheritanceTest(TestCase):
381380
'panes': [
382381
{
383382
'shell_command': ['htop'],
384-
'start_directory': '/etc/'
385383
}
386384
]
387385
},
@@ -407,9 +405,9 @@ class InheritanceTest(TestCase):
407405
'start_directory': '~',
408406
'panes': [
409407
{
410-
'start_directory': '~', 'shell_command': ['vim'],
408+
'shell_command': ['vim'],
411409
}, {
412-
'shell_command': ['cowsay "hey"'], 'start_directory': '~',
410+
'shell_command': ['cowsay "hey"'],
413411
},
414412
],
415413
'layout': 'main-verticle'
@@ -419,23 +417,22 @@ class InheritanceTest(TestCase):
419417
'panes': [
420418
{
421419
'shell_command': ['tail -F /var/log/syslog'],
422-
'start_directory':'/var/log'
423420
}
424421
]
425422
},
426423
{
427424
'window_name': 'shufu',
428425
'panes': [
429426
{
430-
'shell_command': ['htop'], 'start_directory': '/etc/'
427+
'shell_command': ['htop'],
431428
}
432429
]
433430
},
434431
{
435432
'options': {'automatic_rename': True, },
436433
'panes': [
437434
{
438-
'shell_command': ['htop'], 'start_directory':'/'
435+
'shell_command': ['htop'],
439436
}
440437
]
441438
}
@@ -458,12 +455,13 @@ def test_start_directory(self):
458455
window_start_directory = session_start_directory
459456

460457
for paneconfitem in windowconfitem['panes']:
461-
if 'start_directory' in paneconfitem:
462-
pane_start_directory = paneconfitem['start_directory']
463-
elif window_start_directory:
464-
paneconfitem['start_directory'] = window_start_directory
465-
elif session_start_directory:
466-
paneconfitem['start_directory'] = session_start_directory
458+
# if 'start_directory' in paneconfitem:
459+
# pane_start_directory = paneconfitem['start_directory']
460+
# elif window_start_directory:
461+
# paneconfitem['start_directory'] = window_start_directory
462+
# elif session_start_directory:
463+
# paneconfitem['start_directory'] = session_start_directory
464+
pass
467465

468466
self.maxDiff = None
469467
self.assertDictEqual(config, self.config_after)
@@ -813,7 +811,8 @@ def test_expands_blank(self):
813811

814812
self.maxDiff = None
815813

816-
test_config = kaptan.Kaptan().import_config(self.yaml_config_file).get()
814+
test_config = kaptan.Kaptan().import_config(
815+
self.yaml_config_file).get()
817816

818817
self.assertDictEqual(
819818
config.expand(test_config),

0 commit comments

Comments
 (0)