@@ -40,7 +40,9 @@ def validate_schema(sconf):
40
40
41
41
if not 'panes' in window :
42
42
raise exc .ConfigError (
43
- 'config window %s requires list of panes' % window ['window_name' ])
43
+ 'config window %s requires list of panes' %
44
+ window ['window_name' ]
45
+ )
44
46
45
47
return True
46
48
@@ -61,7 +63,10 @@ def is_config_file(filename, extensions=['.yml', '.yaml', '.json']):
61
63
return any (filename .endswith (e ) for e in extensions )
62
64
63
65
64
- def in_dir (config_dir = os .path .expanduser ('~/.tmuxp' ), extensions = ['.yml' , '.yaml' , '.json' ]):
66
+ def in_dir (
67
+ config_dir = os .path .expanduser ('~/.tmuxp' ),
68
+ extensions = ['.yml' , '.yaml' , '.json' ]
69
+ ):
65
70
"""Return a list of configs in ``config_dir``.
66
71
67
72
:param config_dir: directory to search
@@ -74,7 +79,8 @@ def in_dir(config_dir=os.path.expanduser('~/.tmuxp'), extensions=['.yml', '.yaml
74
79
configs = []
75
80
76
81
for filename in os .listdir (config_dir ):
77
- if is_config_file (filename , extensions ) and not filename .startswith ('.' ):
82
+ if is_config_file (filename , extensions ) and \
83
+ not filename .startswith ('.' ):
78
84
configs .append (filename )
79
85
80
86
return configs
@@ -106,12 +112,20 @@ def inline(sconf):
106
112
107
113
"""
108
114
109
- if ('shell_command' in sconf and isinstance (sconf ['shell_command' ], list ) and len (sconf ['shell_command' ]) == 1 ):
115
+ if (
116
+ 'shell_command' in sconf and
117
+ isinstance (sconf ['shell_command' ], list ) and
118
+ len (sconf ['shell_command' ]) == 1
119
+ ):
110
120
sconf ['shell_command' ] = sconf ['shell_command' ][0 ]
111
121
112
122
if len (sconf .keys ()) == int (1 ):
113
123
sconf = sconf ['shell_command' ]
114
- if ('shell_command_before' in sconf and isinstance (sconf ['shell_command_before' ], list ) and len (sconf ['shell_command_before' ]) == 1 ):
124
+ if (
125
+ 'shell_command_before' in sconf and
126
+ isinstance (sconf ['shell_command_before' ], list ) and
127
+ len (sconf ['shell_command_before' ]) == 1
128
+ ):
115
129
sconf ['shell_command_before' ] = sconf ['shell_command_before' ][0 ]
116
130
117
131
# recurse into window and pane config items
@@ -153,22 +167,28 @@ def expand(sconf, cwd=None):
153
167
if not cwd :
154
168
cwd = os .getcwd ()
155
169
156
-
157
170
# Any config section, session, window, pane that can contain the
158
171
# 'shell_command' value
159
172
if 'start_directory' in sconf :
160
- if any (sconf ['start_directory' ].startswith (a ) for a in ['.' , './' ]):
161
- sconf ['start_directory' ] = os .path .normpath (os .path .join (cwd , sconf ['start_directory' ]))
162
- elif any (sconf ['start_directory' ] == a for a in ['.' , './' ]):
163
- sconf ['start_directory' ] = os .path .normpath (os .path .join (cwd , sconf ['start_directory' ]))
164
-
165
- if ('shell_command' in sconf and isinstance (sconf ['shell_command' ], basestring )):
173
+ if (
174
+ any (sconf ['start_directory' ].startswith (a ) for a in ['.' , './' ]) or
175
+ any (sconf ['start_directory' ] == a for a in ['.' , './' ])
176
+ ):
177
+ start_path = os .path .normpath (
178
+ os .path .join (cwd , sconf ['start_directory' ])
179
+ )
180
+ sconf ['start_directory' ] = start_path
181
+
182
+ if (
183
+ 'shell_command' in sconf and
184
+ isinstance (sconf ['shell_command' ], basestring )
185
+ ):
166
186
sconf ['shell_command' ] = [sconf ['shell_command' ]]
167
- # elif not 'windows' in sconf and not 'panes' in sconf and isinstance(sconf, basestring): # probable pane
168
- # logger.error(sconf)
169
- # sconf = {'shell_command': [sconf]}
170
187
171
- if ('shell_command_before' in sconf and isinstance (sconf ['shell_command_before' ], basestring )):
188
+ if (
189
+ 'shell_command_before' in sconf and
190
+ isinstance (sconf ['shell_command_before' ], basestring )
191
+ ):
172
192
sconf ['shell_command_before' ] = [sconf ['shell_command_before' ]]
173
193
174
194
# recurse into window and pane config items
@@ -181,12 +201,12 @@ def expand(sconf, cwd=None):
181
201
for p in sconf ['panes' ]:
182
202
p_index = sconf ['panes' ].index (p )
183
203
184
- if not isinstance (p , dict ) and not isinstance (p , list ): # probable pane
204
+ if not isinstance (p , dict ) and not isinstance (p , list ):
185
205
p = sconf ['panes' ][p_index ] = {
186
206
'shell_command' : [p ]
187
207
}
188
208
189
- if isinstance (p , dict ) and not len (p ):
209
+ if isinstance (p , dict ) and not len (p ):
190
210
p = sconf ['panes' ][p_index ] = {
191
211
'shell_command' : []
192
212
}
@@ -208,11 +228,16 @@ def expand(sconf, cwd=None):
208
228
p = sconf ['panes' ][p_index ] = {
209
229
'shell_command' : []
210
230
}
211
- elif isinstance (p ['shell_command' ], list ) and \
212
- len (p ['shell_command' ]) == int (1 ) and (
213
- any (a in p ['shell_command' ] for a in [None , 'blank' , 'pane' ]) or \
214
- p ['shell_command' ][0 ] is None
215
- ):
231
+ elif (
232
+ isinstance (p ['shell_command' ], list ) and (
233
+ len (p ['shell_command' ]) == int (1 ) and (
234
+ any (
235
+ a in p ['shell_command' ]
236
+ for a in [None , 'blank' , 'pane' ]
237
+ ) or p ['shell_command' ][0 ] is None
238
+ )
239
+ )
240
+ ):
216
241
p = sconf ['panes' ][p_index ] = {
217
242
'shell_command' : []
218
243
}
@@ -253,9 +278,14 @@ def trickle(sconf):
253
278
if not 'start_directory' in windowconfig :
254
279
windowconfig ['start_directory' ] = session_start_directory
255
280
else :
256
- if not any (windowconfig ['start_directory' ].startswith (a ) for a in ['~' , '/' ]):
257
- windowconfig ['start_directory' ] = os .path .join (
258
- session_start_directory , windowconfig ['start_directory' ])
281
+ if not any (
282
+ windowconfig ['start_directory' ].startswith (a )
283
+ for a in ['~' , '/' ]
284
+ ):
285
+ window_start_path = os .path .join (
286
+ session_start_directory , windowconfig ['start_directory' ]
287
+ )
288
+ windowconfig ['start_directory' ] = window_start_path
259
289
260
290
for paneconfig in windowconfig ['panes' ]:
261
291
commands_before = []
0 commit comments