@@ -277,48 +277,48 @@ def reattach(session):
277
277
else :
278
278
sys .exit ('Session created in detached state.' )
279
279
280
- if not detached :
281
-
282
- if has_gte_version ('2.6' ):
283
- # tmuxp issue: https://github.com/tony/tmuxp/issues/309
284
- # tmux issue: https://github.com/tmux/tmux/issues/1106
285
- #
286
- # tmux now requires that the window be viewed with the client
287
- # before select-layout adjustments can be meaningful
288
- #
289
- # To handle this, let's create a temporary hook for this
290
- # session to iterage and run select-layout on all windows
291
- # after client attaches.
292
- cmd = [
293
- 'set-hook' ,
294
- '-t' , builder .session .id ,
295
- 'client-attached'
296
- ]
297
- hook_cmd = []
298
- for window in builder .session .windows :
299
- # unfortunately, select-layout won't work unless
300
- # we've literally selected the window at least once
301
- # with the client
302
- hook_cmd .append ('selectw -t {}' .format (window .id ))
303
- # edit: removed -t, or else it won't respect main-pane-w/h
304
- hook_cmd .append ('selectl' .format (window .id ))
305
- hook_cmd .append ('selectw -p' .format (window .id ))
306
-
307
- # unset the hook immediately after executing
308
- hook_cmd .append (
309
- 'set-hook -u -t {target_session} client-attached' .format (
310
- target_session = builder .session .id
311
- )
280
+ if has_gte_version ('2.6' ):
281
+ # tmuxp issue: https://github.com/tony/tmuxp/issues/309
282
+ # tmux issue: https://github.com/tmux/tmux/issues/1106
283
+ #
284
+ # tmux now requires that the window be viewed with the client
285
+ # before select-layout adjustments can be meaningful
286
+ #
287
+ # To handle this, let's create a temporary hook for this
288
+ # session to iterage and run select-layout on all windows
289
+ # after client attaches.
290
+ cmd = [
291
+ 'set-hook' ,
292
+ '-t' , builder .session .id ,
293
+ 'client-attached'
294
+ ]
295
+ hook_cmd = []
296
+ for window in builder .session .windows :
297
+ # unfortunately, select-layout won't work unless
298
+ # we've literally selected the window at least once
299
+ # with the client
300
+ hook_cmd .append ('selectw -t {}' .format (window .id ))
301
+ # edit: removed -t, or else it won't respect main-pane-w/h
302
+ hook_cmd .append ('selectl' .format (window .id ))
303
+ hook_cmd .append ('selectw -p' .format (window .id ))
304
+
305
+ # unset the hook immediately after executing
306
+ hook_cmd .append (
307
+ 'set-hook -u -t {target_session} client-attached' .format (
308
+ target_session = builder .session .id
312
309
)
310
+ )
311
+
312
+ # join the hook's commands with semicolons
313
+ hook_cmd = '{}' .format ('; ' .join (hook_cmd ))
313
314
314
- # join the hook's commands with semicolons
315
- hook_cmd = '{}' . format ( '; ' . join ( hook_cmd ) )
315
+ # append the hook command
316
+ cmd . append ( hook_cmd )
316
317
317
- # append the hook command
318
- cmd . append ( hook_cmd )
318
+ # create the hook
319
+ builder . session . cmd ( * cmd )
319
320
320
- # create the hook
321
- builder .session .cmd (* cmd )
321
+ if not detached :
322
322
builder .session .attach_session ()
323
323
324
324
except exc .TmuxpException as e :
0 commit comments