File tree Expand file tree Collapse file tree 2 files changed +77
-8
lines changed Expand file tree Collapse file tree 2 files changed +77
-8
lines changed Original file line number Diff line number Diff line change @@ -238,9 +238,9 @@ def expand(sconf, cwd=None):
238
238
)
239
239
)
240
240
):
241
- p = sconf ['panes' ][p_index ] = {
242
- 'shell_command' : []
243
- }
241
+ p = sconf ['panes' ][p_index ] = {
242
+ 'shell_command' : []
243
+ }
244
244
245
245
sconf ['panes' ] = [expand (pane ) for pane in sconf ['panes' ]]
246
246
@@ -292,18 +292,18 @@ def trickle(sconf):
292
292
293
293
# Prepend shell_command_before to commands
294
294
if 'shell_command_before' in sconf :
295
- commands_before = sconf ['shell_command_before' ]
295
+ commands_before . extend ( sconf ['shell_command_before' ])
296
296
if 'shell_command_before' in windowconfig :
297
297
commands_before .extend (windowconfig ['shell_command_before' ])
298
298
if 'shell_command_before' in paneconfig :
299
299
commands_before .extend (paneconfig ['shell_command_before' ])
300
- if 'shell_command' not in paneconfig :
301
- paneconfig ['shell_command' ] = list ()
302
300
303
- if paneconfig [ 'shell_command' ] :
301
+ if 'shell_command' in paneconfig :
304
302
commands_before .extend (paneconfig ['shell_command' ])
305
303
306
- paneconfig ['shell_command' ] = commands_before
304
+ p_index = windowconfig ['panes' ].index (paneconfig )
305
+ windowconfig ['panes' ][p_index ]['shell_command' ] = commands_before
306
+ #paneconfig['shell_command'] = commands_before
307
307
308
308
return sconf
309
309
Original file line number Diff line number Diff line change @@ -664,6 +664,75 @@ def test_shell_command_before(self):
664
664
self .assertDictEqual (test_config , self .config_after )
665
665
666
666
667
+ class ShellCommandBeforeSession (TestCase ):
668
+
669
+ def test_in_session_scope (self ):
670
+
671
+ yaml_config = """
672
+ shell_command_before:
673
+ - 'echo "hi"'
674
+ session_name: 'test'
675
+ windows:
676
+ - window_name: editor
677
+ panes:
678
+ - shell_command:
679
+ - vim
680
+ - :Ex
681
+ - pane
682
+ - cd /usr
683
+ - window_name: logging
684
+ panes:
685
+ - shell_command:
686
+ -
687
+ - shell_command:
688
+ - top
689
+ - emacs
690
+ """
691
+
692
+ yaml_final_config = """
693
+ shell_command_before:
694
+ - 'echo "hi"'
695
+ session_name: 'test'
696
+ windows:
697
+ - window_name: editor
698
+ panes:
699
+ - shell_command:
700
+ - 'echo "hi"'
701
+ - vim
702
+ - :Ex
703
+ - shell_command:
704
+ - 'echo "hi"'
705
+ - shell_command:
706
+ - 'echo "hi"'
707
+ - cd /usr
708
+ - window_name: logging
709
+ panes:
710
+ - shell_command:
711
+ - 'echo "hi"'
712
+ - shell_command:
713
+ - 'echo "hi"'
714
+ - top
715
+ - emacs
716
+ """
717
+
718
+ self .maxDiff = None
719
+
720
+ sconfig = kaptan .Kaptan (handler = 'yaml' )
721
+ sconfig = sconfig .import_config (yaml_config ).get ()
722
+
723
+ config .validate_schema (sconfig )
724
+
725
+ self .assertDictEqual (config .expand (sconfig ), sconfig )
726
+
727
+ self .assertDictEqual (
728
+ config .expand (config .trickle (sconfig )),
729
+ self .yaml_to_dict (yaml_final_config )
730
+ )
731
+
732
+ def yaml_to_dict (self , yaml ):
733
+ return kaptan .Kaptan (handler = 'yaml' ).import_config (yaml ).get ()
734
+
735
+
667
736
class TrickleRelativeStartDirectory (TestCase ):
668
737
669
738
config_expanded = { # shell_command_before is string in some areas
You can’t perform that action at this time.
0 commit comments