diff --git a/CHANGELOG.md b/CHANGELOG.md index 7af862c..8e66e64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - do not save pane contents if pane is empty (only for 'save pane contents' feature) - "save pane contents" feature saves files to a separate directory +- archive and compress pane contents file ### v2.4.0, 2015-02-23 - add "tmux-test" diff --git a/scripts/helpers.sh b/scripts/helpers.sh index b34c100..b1429d6 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -71,6 +71,23 @@ is_session_grouped() { [[ "$GROUPED_SESSIONS" == *"${d}${session_name}${d}"* ]] } +# pane content file helpers + +pane_contents_create_archive() { + tar czf "$(pane_contents_archive_file)" -C "$(resurrect_dir)" ./pane_contents/ +} + +pane_content_files_restore_from_archive() { + local archive_file="$(pane_contents_archive_file)" + if [ -f "$archive_file" ]; then + tar xzf "$archive_file" -C "$(resurrect_dir)" + fi +} + +pane_content_files_cleanup() { + rm "$(pane_contents_dir)"/* +} + # path helpers resurrect_dir() { @@ -101,6 +118,10 @@ pane_contents_file_exists() { [ -f "$(pane_contents_file "$pane_id")" ] } +pane_contents_archive_file() { + echo "$(resurrect_dir)/pane_contents.tar.gz" +} + resurrect_history_file() { local pane_id="$1" echo "$(resurrect_dir)/bash_history-${pane_id}" diff --git a/scripts/restore.sh b/scripts/restore.sh index dceaa01..16a19a8 100755 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -250,11 +250,17 @@ detect_if_restoring_pane_contents() { restore_all_panes() { detect_if_restoring_from_scratch # sets a global variable detect_if_restoring_pane_contents # sets a global variable + if is_restoring_pane_contents; then + pane_content_files_restore_from_archive + fi while read line; do if is_line_type "pane" "$line"; then restore_pane "$line" fi done < $(last_resurrect_file) + if is_restoring_pane_contents; then + pane_content_files_cleanup + fi } restore_pane_layout_for_each_window() { diff --git a/scripts/save.sh b/scripts/save.sh index f888b53..63fece9 100755 --- a/scripts/save.sh +++ b/scripts/save.sh @@ -261,6 +261,8 @@ save_all() { if capture_pane_contents_option_on; then mkdir -p "$(pane_contents_dir)" dump_pane_contents + pane_contents_create_archive + pane_content_files_cleanup fi if save_bash_history_option_on; then dump_bash_history