@@ -33,78 +33,34 @@ def teamocil_to_tmuxp(sconf):
3333 if 'session' in sconf :
3434 sconf = sconf ['session' ]
3535
36- if 'project_name' in sconf :
37- tmuxp_config ['session_name' ] = sconf ['project_name' ]
38- elif 'name' in sconf :
36+ if 'name' in sconf :
3937 tmuxp_config ['session_name' ] = sconf ['name' ]
4038 else :
4139 tmuxp_config ['session_name' ] = None
4240
43- if 'cli_args' in sconf :
44- tmuxp_config ['config' ] = sconf ['cli_args' ]
45-
46- if '-f' in tmuxp_config ['config' ]:
47- tmuxp_config ['config' ] = tmuxp_config [
48- 'config' ].replace ('-f' , '' ).strip ()
49- elif 'tmux_options' in sconf :
50- tmuxp_config ['config' ] = sconf ['tmux_options' ]
51-
52- if '-f' in tmuxp_config ['config' ]:
53- tmuxp_config ['config' ] = tmuxp_config [
54- 'config' ].replace ('-f' , '' ).strip ()
55-
56- if 'socket_name' in sconf :
57- tmuxp_config ['socket_name' ] = sconf ['socket_name' ]
58-
5941 tmuxp_config ['windows' ] = []
6042
61- if 'tabs' in sconf :
62- sconf ['windows' ] = sconf .pop ('tabs' )
63-
64- if 'pre' in sconf and 'pre_window' in sconf :
65- tmuxp_config ['shell_command' ] = sconf ['pre' ]
66-
67- if isinstance (sconf ['pre' ], basestring ):
68- tmuxp_config ['shell_command_before' ] = [sconf ['pre_window' ]]
69- else :
70- tmuxp_config ['shell_command_before' ] = sconf ['pre_window' ]
71- elif 'pre' in sconf :
72- if isinstance (sconf ['pre' ], basestring ):
73- tmuxp_config ['shell_command_before' ] = [sconf ['pre' ]]
74- else :
75- tmuxp_config ['shell_command_before' ] = sconf ['pre' ]
76-
77- if 'rbenv' in sconf :
78- if 'shell_command_before' not in tmuxp_config :
79- tmuxp_config ['shell_command_before' ] = []
80- tmuxp_config ['shell_command_before' ].append (
81- 'rbenv shell %s' % sconf ['rbenv' ]
82- )
83-
8443 for w in sconf ['windows' ]:
85- for k , v in w .items ():
86-
87- windowdict = {}
8844
89- windowdict [ 'window_name' ] = k
45+ windowdict = {}
9046
91- if isinstance (v , basestring ) or v is None :
92- windowdict ['panes' ] = [v ]
93- tmuxp_config ['windows' ].append (windowdict )
94- continue
95- elif isinstance (v , list ):
96- windowdict ['panes' ] = v
97- tmuxp_config ['windows' ].append (windowdict )
98- continue
47+ if 'filters' in w :
48+ if 'before' in w ['filters' ]:
49+ for b in w ['filters' ]['before' ]:
50+ windowdict ['shell_command_before' ] = w ['filters' ]['before' ]
51+ if 'after' in w ['filters' ]:
52+ for b in w ['filters' ]['after' ]:
53+ windowdict ['shell_command_after' ] = w ['filters' ]['after' ]
9954
100- if 'pre' in v :
101- windowdict ['shell_command_before' ] = v ['pre' ]
102- if 'panes' in v :
103- windowdict ['panes' ] = v ['panes' ]
55+ if 'panes' in w :
56+ for p in w ['panes' ]:
57+ if 'cmd' in p :
58+ p ['shell_command' ] = p .pop ('cmd' )
59+ windowdict ['panes' ] = w ['panes' ]
10460
105- if 'layout' in v :
106- windowdict ['layout' ] = v ['layout' ]
107- tmuxp_config ['windows' ].append (windowdict )
61+ if 'layout' in w :
62+ windowdict ['layout' ] = w ['layout' ]
63+ tmuxp_config ['windows' ].append (windowdict )
10864
10965 return tmuxp_config
11066
@@ -596,7 +552,7 @@ class TeamocilLayoutsTest(unittest.TestCase):
596552
597553 two_windows_with_filters = \
598554 {
599- 'session-name ' : 'two-windows-with-filters' ,
555+ 'session_name ' : 'two-windows-with-filters' ,
600556 'windows' : [
601557 {
602558 'window_name' : 'foo' ,
@@ -622,7 +578,7 @@ class TeamocilLayoutsTest(unittest.TestCase):
622578
623579 two_windows_with_custom_command_options = \
624580 {
625- 'session-name ' : 'two-windows-with-custom-command-options' ,
581+ 'session_name ' : 'two-windows-with-custom-command-options' ,
626582 'windows' : [
627583 {
628584 'window_name' : 'foo' ,
0 commit comments