Skip to content

Commit dc14383

Browse files
committed
Resurrect session options
1 parent 988b8fd commit dc14383

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

scripts/restore.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,14 @@ restore_active_and_alternate_sessions() {
362362
done < $(last_resurrect_file)
363363
}
364364

365+
restore_session_options() {
366+
\grep '^option_session' $(last_resurrect_file) |
367+
while IFS=$d read line_type session_name option value; do
368+
value=$(echo $value | sed 's/"\(.*\)"/\1/')
369+
tmux set-option -t "${session_name}:" "${option}" "${value}"
370+
done
371+
}
372+
365373
# A cleanup that happens after 'restore_all_panes' seems to fix fish shell
366374
# users' restore problems.
367375
cleanup_restored_pane_contents() {
@@ -386,6 +394,7 @@ main() {
386394
restore_grouped_sessions # also restores active and alt windows for grouped sessions
387395
restore_active_and_alternate_windows
388396
restore_active_and_alternate_sessions
397+
restore_session_options
389398
cleanup_restored_pane_contents
390399
execute_hook "post-restore-all"
391400
stop_spinner

scripts/save.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,16 @@ dump_windows() {
258258
done
259259
}
260260

261+
dump_session_options() {
262+
tmux list-sessions -F "#{session_name}" |
263+
while read session_name; do
264+
tmux show-options -t "${session_name}:" |
265+
while read option value; do
266+
echo "option_session${d}${session_name}${d}${option}${d}${value}"
267+
done
268+
done
269+
}
270+
261271
dump_state() {
262272
tmux display-message -p "$(state_format)"
263273
}
@@ -291,6 +301,7 @@ save_all() {
291301
dump_panes >> "$resurrect_file_path"
292302
dump_windows >> "$resurrect_file_path"
293303
dump_state >> "$resurrect_file_path"
304+
dump_session_options >> "$resurrect_file_path"
294305
execute_hook "post-save-layout" "$resurrect_file_path"
295306
if files_differ "$resurrect_file_path" "$last_resurrect_file"; then
296307
ln -fs "$(basename "$resurrect_file_path")" "$last_resurrect_file"

0 commit comments

Comments
 (0)