@@ -25,6 +25,18 @@ grouped_sessions_format() {
25
25
echo " $format "
26
26
}
27
27
28
+ linked_windows_format () {
29
+ local format
30
+ format+=" #{window_linked}"
31
+ format+=" ${delimiter} "
32
+ format+=" #{window_id}"
33
+ format+=" ${delimiter} "
34
+ format+=" #{session_name}"
35
+ format+=" ${delimiter} "
36
+ format+=" #{window_index}"
37
+ echo " $format "
38
+ }
39
+
28
40
pane_format () {
29
41
local format
30
42
format+=" pane"
@@ -185,13 +197,45 @@ fetch_and_dump_grouped_sessions(){
185
197
fi
186
198
}
187
199
200
+ dump_linked_windows () {
201
+ local current_window_id=" "
202
+ local original_session
203
+ local original_window_index
204
+ tmux list-windows -a -F " $( linked_windows_format) " |
205
+ grep " ^1" |
206
+ cut -c 3- |
207
+ sort |
208
+ while IFS=$d read window_id session_name window_index; do
209
+ if is_session_grouped " $session_name " ; then
210
+ continue
211
+ fi
212
+ if [ " $window_id " != " $current_window_id " ]; then
213
+ # this window is the original/first of linked windows
214
+ original_session=" $session_name "
215
+ original_window_index=" $window_index "
216
+ current_window_id=" $window_id "
217
+ else
218
+ # this window is linked to the original window
219
+ echo " linked_window${d}${session_name}${d}${window_index}${d}${original_session}${d}${original_window_index} "
220
+ fi
221
+ done
222
+ }
223
+
224
+ fetch_and_dump_linked_windows () {
225
+ local linked_windows_dump=" $( dump_linked_windows) "
226
+ get_linked_windows " $linked_windows_dump "
227
+ if [ -n " $linked_windows_dump " ]; then
228
+ echo " $linked_windows_dump "
229
+ fi
230
+ }
231
+
188
232
# translates pane pid to process command running inside a pane
189
233
dump_panes () {
190
234
local full_command
191
235
dump_panes_raw |
192
236
while IFS=$d read line_type session_name window_number window_active window_flags pane_index pane_title dir pane_active pane_command pane_pid history_size; do
193
237
# not saving panes from grouped sessions
194
- if is_session_grouped " $session_name " ; then
238
+ if is_session_grouped " $session_name " || is_window_linked " $session_name " " $window_number " ; then
195
239
continue
196
240
fi
197
241
full_command=" $( pane_full_command $pane_pid ) "
@@ -240,6 +284,7 @@ save_all() {
240
284
local last_resurrect_file=" $( last_resurrect_file) "
241
285
mkdir -p " $( resurrect_dir) "
242
286
fetch_and_dump_grouped_sessions > " $resurrect_file_path "
287
+ fetch_and_dump_linked_windows >> " $resurrect_file_path "
243
288
dump_panes >> " $resurrect_file_path "
244
289
dump_windows >> " $resurrect_file_path "
245
290
dump_state >> " $resurrect_file_path "
0 commit comments